diff options
author | IGARASHI Masanao <syoux2@gmail.com> | 2014-05-30 00:52:34 +0900 |
---|---|---|
committer | IGARASHI Masanao <syoux2@gmail.com> | 2014-05-30 00:52:34 +0900 |
commit | 069f6e1b0e5d9445d9f91a2c6711d02d3a146296 (patch) | |
tree | f705348a88db7a73e36ff60f58d0de34510646a4 | |
parent | 30685d06840e18f28e7c88d1bc251e7e5e8a130d (diff) | |
download | dogpile-cache-069f6e1b0e5d9445d9f91a2c6711d02d3a146296.tar.gz |
add connection_pool parameter for the redis backend
-rw-r--r-- | dogpile/cache/backends/redis.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/dogpile/cache/backends/redis.py b/dogpile/cache/backends/redis.py index 3080ca0..9cf301d 100644 --- a/dogpile/cache/backends/redis.py +++ b/dogpile/cache/backends/redis.py @@ -74,6 +74,8 @@ class RedisBackend(CacheBackend): .. versionadded:: 0.5.0 + :param connection_pool: ``redis.ConnectionPool`` object, default is ``None`` + """ def __init__(self, arguments): @@ -89,6 +91,7 @@ class RedisBackend(CacheBackend): self.lock_sleep = arguments.get('lock_sleep', 0.1) self.redis_expiration_time = arguments.pop('redis_expiration_time', 0) + self.connection_pool = arguments.get('connection_pool', None) self.client = self._create_client() def _imports(self): @@ -97,7 +100,9 @@ class RedisBackend(CacheBackend): import redis def _create_client(self): - if self.url is not None: + if self.connection_pool is not None: + return redis.StrictRedis(connection_pool=self.connection_pool) + elif self.url is not None: return redis.StrictRedis.from_url(url=self.url) else: return redis.StrictRedis(host=self.host, password=self.password, |