Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions redis_cache/rediscache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]",
description="redis-simple-cache is a pythonic interface for creating a cache over redis. "
Expand Down