harp_apps.storage.services.redis¶
- class Redis[source]¶
Bases:
Redis
Initialize a new Redis client. To specify a retry policy for specific errors, first set retry_on_error to a list of the error/s to retry on, then set retry to a valid Retry object. To retry on TimeoutError, retry_on_timeout can also be set to True.
- classmethod from_url(url, single_connection_client=False, auto_close_connection_pool=None, **kwargs)[source]¶
Return a Redis client object configured from the given URL
For example:
redis://[[username]:[password]]@localhost:6379/0 rediss://[[username]:[password]]@localhost:6379/0 unix://[username@]/path/to/socket.sock?db=0[&password=password]
Three URL schemes are supported:
redis:// creates a TCP socket connection. See more at: <https://www.iana.org/assignments/uri-schemes/prov/redis>
rediss:// creates a SSL wrapped TCP socket connection. See more at: <https://www.iana.org/assignments/uri-schemes/prov/rediss>
unix://
: creates a Unix Domain Socket connection.
The username, password, hostname, path and all querystring values are passed through urllib.parse.unquote in order to replace any percent-encoded values with their corresponding characters.
There are several ways to specify a database number. The first value found will be used:
A
db
querystring option, e.g. redis://localhost?db=0- If using the redis:// or rediss:// schemes, the path argument
of the url, e.g. redis://localhost/0
A
db
keyword argument to this function.
If none of these options are specified, the default db=0 is used.
All querystring options are cast to their appropriate Python types. Boolean arguments can be specified with string values “True”/”False” or “Yes”/”No”. Values that cannot be properly cast cause a
ValueError
to be raised. Once parsed, the querystring arguments and keyword arguments are passed to theConnectionPool
’s class initializer. In the case of conflicting arguments, querystring arguments always win.