Commit 4f96e6db authored by Jannis Leidel's avatar Jannis Leidel Committed by Sean Bleier

Allow overriding of used database and password. E.g., use this to use a different database:

CACHE_BACKEND = 'redis_cache.cache://127.0.0.1:6379?db=2'
parent dd84fe45
...@@ -21,7 +21,22 @@ class CacheClass(BaseCache): ...@@ -21,7 +21,22 @@ class CacheClass(BaseCache):
Connect to Redis, and set up cache backend. Connect to Redis, and set up cache backend.
""" """
BaseCache.__init__(self, params) BaseCache.__init__(self, params)
self._cache = redis.Redis(server.split(':')[0], db=1) db = params.get('db', 1)
try:
db = int(db)
except (ValueError, TypeError):
db = 1
password = params.get('password', None)
if ':' in server:
host, port = server.split(':')
try:
port = int(port)
except (ValueError, TypeError):
port = 6379
else:
host = 'localhost'
port = 6379
self._cache = redis.Redis(host=host, port=port, db=db, password=None)
def add(self, key, value, timeout=0): def add(self, key, value, timeout=0):
""" """
......
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