diff --git a/redis_cache/rediscache.py b/redis_cache/rediscache.py index f951bd8..f8a0887 100644 --- a/redis_cache/rediscache.py +++ b/redis_cache/rediscache.py @@ -17,11 +17,12 @@ class RedisConnect(object): This makes the Simple Cache class a little more flexible, for cases where redis connection configuration needs customizing. """ - def __init__(self, host=None, port=None, db=None, password=None): + def __init__(self, host=None, port=None, db=None, password=None, ssl=False): self.host = host if host else 'localhost' self.port = port if port else 6379 self.db = db if db else 0 self.password = password + self.ssl = ssl def connect(self): """ @@ -31,7 +32,7 @@ def connect(self): :return: redis.StrictRedis Connection Object """ try: - redis.StrictRedis(host=self.host, port=self.port, password=self.password).ping() + redis.StrictRedis(host=self.host, port=self.port, password=self.password, ssl=self.ssl).ping() except redis.ConnectionError as e: raise RedisNoConnException("Failed to create connection to redis", (self.host, @@ -76,6 +77,8 @@ def __init__(self, port=None, db=None, password=None, + ssl=False, + client=None, namespace="SimpleCache"): self.limit = limit # No of json encoded strings to cache @@ -86,10 +89,14 @@ def __init__(self, self.db = db try: - self.connection = RedisConnect(host=self.host, - port=self.port, - db=self.db, - password=password).connect() + if client: + self.connection = client + else: + self.connection = RedisConnect(host=self.host, + port=self.port, + db=self.db, + password=password, + ssl=ssl).connect() except RedisNoConnException, e: self.connection = None pass diff --git a/setup.py b/setup.py index ac2a2ea..9dc585a 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ def openf(fname): setup( name="redis-simple-cache", - version="0.0.6", + version="0.0.7", author="Vivek Narayanan, Flávio Juvenal, Sam Zaydel", author_email="flaviojuvenal@gmail.com", description="redis-simple-cache is a pythonic interface for creating a cache over redis. "