Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sebleier committed May 16, 2012
2 parents dc63e94 + ab08444 commit 17d8ab6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions redis_cache/cache.py
Expand Up @@ -38,12 +38,15 @@ def __unicode__(self):


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,
password=None, parser_class=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 = (
unix_socket_path and UnixDomainSocketConnection or Connection
)
Expand All @@ -60,8 +63,8 @@ def get_connection_pool(self, host='127.0.0.1', port=6379, db=1,
})
else:
kwargs['path'] = unix_socket_path
self._connection_pool = redis.ConnectionPool(**kwargs)
return self._connection_pool
self._connection_pools[connection_identifier] = redis.ConnectionPool(**kwargs)
return self._connection_pools[connection_identifier]
pool = CacheConnectionPool()


Expand Down

0 comments on commit 17d8ab6

Please sign in to comment.