Implementation of the Redis protocol. This abstract class provides a Python interface to all Redis commands and an implementation of the Redis protocol. Pipelines derive from this, implementing how the commands are sent and received to the Redis server. Based on configurat
| 122 | |
| 123 | |
| 124 | class Redis( |
| 125 | AbstractRedis, AsyncRedisModuleCommands, AsyncCoreCommands, AsyncSentinelCommands |
| 126 | ): |
| 127 | """ |
| 128 | Implementation of the Redis protocol. |
| 129 | |
| 130 | This abstract class provides a Python interface to all Redis commands |
| 131 | and an implementation of the Redis protocol. |
| 132 | |
| 133 | Pipelines derive from this, implementing how |
| 134 | the commands are sent and received to the Redis server. Based on |
| 135 | configuration, an instance will either use a ConnectionPool, or |
| 136 | Connection object to talk to redis. |
| 137 | """ |
| 138 | |
| 139 | # Type discrimination marker for @overload self-type pattern |
| 140 | _is_async_client: Literal[True] = True |
| 141 | |
| 142 | response_callbacks: MutableMapping[Union[str, bytes], ResponseCallbackT] |
| 143 | |
| 144 | @classmethod |
| 145 | def from_url( |
| 146 | cls: Type["Redis"], |
| 147 | url: str, |
| 148 | single_connection_client: bool = False, |
| 149 | auto_close_connection_pool: Optional[bool] = None, |
| 150 | **kwargs, |
| 151 | ) -> "Redis": |
| 152 | """ |
| 153 | Return a Redis client object configured from the given URL |
| 154 | |
| 155 | For example:: |
| 156 | |
| 157 | redis://[[username]:[password]]@localhost:6379/0 |
| 158 | rediss://[[username]:[password]]@localhost:6379/0 |
| 159 | unix://[username@]/path/to/socket.sock?db=0[&password=password] |
| 160 | |
| 161 | Three URL schemes are supported: |
| 162 | |
| 163 | - `redis://` creates a TCP socket connection. See more at: |
| 164 | <https://www.iana.org/assignments/uri-schemes/prov/redis> |
| 165 | - `rediss://` creates a SSL wrapped TCP socket connection. See more at: |
| 166 | <https://www.iana.org/assignments/uri-schemes/prov/rediss> |
| 167 | - ``unix://``: creates a Unix Domain Socket connection. |
| 168 | |
| 169 | The username, password, hostname, path and all querystring values |
| 170 | are passed through urllib.parse.unquote in order to replace any |
| 171 | percent-encoded values with their corresponding characters. |
| 172 | |
| 173 | There are several ways to specify a database number. The first value |
| 174 | found will be used: |
| 175 | |
| 176 | 1. A ``db`` querystring option, e.g. redis://localhost?db=0 |
| 177 | |
| 178 | 2. If using the redis:// or rediss:// schemes, the path argument |
| 179 | of the url, e.g. redis://localhost/0 |
| 180 | |
| 181 | 3. A ``db`` keyword argument to this function. |
no outgoing calls