2424
2525
2626class RedisBackend (BytesBackend ):
27- """A `Redis <http://redis.io/>`_ backend, using the
27+ r """A `Redis <http://redis.io/>`_ backend, using the
2828 `redis-py <http://pypi.python.org/pypi/redis/>`_ backend.
2929
3030 Example configuration::
@@ -88,6 +88,14 @@ class RedisBackend(BytesBackend):
8888 asynchronous runners, as they run in a different thread than the one
8989 used to create the lock.
9090
91+ :param connection_kwargs: dict, additional keyword arguments are passed
92+ along to the
93+ ``StrictRedis.from_url()`` method or ``StrictRedis()`` constructor
94+ directly, including parameters like ``ssl``, ``ssl_certfile``,
95+ ``charset``, etc.
96+
97+ .. versionadded:: 1.1.6 Added ``connection_kwargs`` parameter.
98+
9199 """
92100
93101 def __init__ (self , arguments ):
@@ -98,12 +106,12 @@ def __init__(self, arguments):
98106 self .password = arguments .pop ("password" , None )
99107 self .port = arguments .pop ("port" , 6379 )
100108 self .db = arguments .pop ("db" , 0 )
101- self .distributed_lock = arguments .get ("distributed_lock" , False )
109+ self .distributed_lock = arguments .pop ("distributed_lock" , False )
102110 self .socket_timeout = arguments .pop ("socket_timeout" , None )
103-
104- self .lock_timeout = arguments .get ( "lock_timeout " , None )
105- self .lock_sleep = arguments .get ( "lock_sleep " , 0.1 )
106- self .thread_local_lock = arguments .get ( "thread_local_lock " , True )
111+ self . lock_timeout = arguments . pop ( "lock_timeout" , None )
112+ self .lock_sleep = arguments .pop ( "lock_sleep " , 0.1 )
113+ self .thread_local_lock = arguments .pop ( "thread_local_lock " , True )
114+ self .connection_kwargs = arguments .pop ( "connection_kwargs " , {} )
107115
108116 if self .distributed_lock and self .thread_local_lock :
109117 warnings .warn (
@@ -112,7 +120,7 @@ def __init__(self, arguments):
112120 )
113121
114122 self .redis_expiration_time = arguments .pop ("redis_expiration_time" , 0 )
115- self .connection_pool = arguments .get ("connection_pool" , None )
123+ self .connection_pool = arguments .pop ("connection_pool" , None )
116124 self ._create_client ()
117125
118126 def _imports (self ):
@@ -131,6 +139,7 @@ def _create_client(self):
131139 self .reader_client = self .writer_client
132140 else :
133141 args = {}
142+ args .update (self .connection_kwargs )
134143 if self .socket_timeout :
135144 args ["socket_timeout" ] = self .socket_timeout
136145
@@ -269,9 +278,11 @@ class RedisSentinelBackend(RedisBackend):
269278 a normal Redis connection can be specified here.
270279 Default is {}.
271280
272- :param connection_kwargs: dict, are keyword arguments that will be used
273- when establishing a connection to a Redis server.
274- Default is {}.
281+ :param connection_kwargs: dict, additional keyword arguments are passed
282+ along to the
283+ ``StrictRedis.from_url()`` method or ``StrictRedis()`` constructor
284+ directly, including parameters like ``ssl``, ``ssl_certfile``,
285+ ``charset``, etc.
275286
276287 :param lock_sleep: integer, number of seconds to sleep when failed to
277288 acquire a lock. This argument is only valid when
@@ -290,7 +301,6 @@ def __init__(self, arguments):
290301 self .sentinels = arguments .pop ("sentinels" , None )
291302 self .service_name = arguments .pop ("service_name" , "mymaster" )
292303 self .sentinel_kwargs = arguments .pop ("sentinel_kwargs" , {})
293- self .connection_kwargs = arguments .pop ("connection_kwargs" , {})
294304
295305 super ().__init__ (
296306 arguments = {
0 commit comments