Commit 17d8ab6c authored by Sean Bleier's avatar Sean Bleier
parents dc63e942 ab084443
...@@ -38,12 +38,15 @@ class CacheKey(object): ...@@ -38,12 +38,15 @@ class CacheKey(object):
class CacheConnectionPool(object): class CacheConnectionPool(object):
_connection_pool = None
def __init__(self):
self._connection_pools = {}
def get_connection_pool(self, host='127.0.0.1', port=6379, db=1, def get_connection_pool(self, host='127.0.0.1', port=6379, db=1,
password=None, parser_class=None, password=None, parser_class=None,
unix_socket_path=None): unix_socket_path=None):
if self._connection_pool is None: connection_identifier = (host, port, db, parser_class, unix_socket_path)
if not self._connection_pools.get(connection_identifier):
connection_class = ( connection_class = (
unix_socket_path and UnixDomainSocketConnection or Connection unix_socket_path and UnixDomainSocketConnection or Connection
) )
...@@ -60,8 +63,8 @@ class CacheConnectionPool(object): ...@@ -60,8 +63,8 @@ class CacheConnectionPool(object):
}) })
else: else:
kwargs['path'] = unix_socket_path kwargs['path'] = unix_socket_path
self._connection_pool = redis.ConnectionPool(**kwargs) self._connection_pools[connection_identifier] = redis.ConnectionPool(**kwargs)
return self._connection_pool return self._connection_pools[connection_identifier]
pool = CacheConnectionPool() pool = CacheConnectionPool()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment