Commit 7361e20c authored by James Aylett's avatar James Aylett

Make cache object picklable.

parent 6504a3d4
...@@ -37,7 +37,11 @@ class CacheClass(BaseCache): ...@@ -37,7 +37,11 @@ class CacheClass(BaseCache):
""" """
Connect to Redis, and set up cache backend. Connect to Redis, and set up cache backend.
""" """
self._init(server, params)
def _init(self, server, params):
super(CacheClass, self).__init__(params) super(CacheClass, self).__init__(params)
self._initargs = { 'server': server, 'params': params }
options = params.get('OPTIONS', {}) options = params.get('OPTIONS', {})
password = params.get('password', options.get('PASSWORD', None)) password = params.get('password', options.get('PASSWORD', None))
db = params.get('db', options.get('DB', 1)) db = params.get('db', options.get('DB', 1))
...@@ -56,6 +60,12 @@ class CacheClass(BaseCache): ...@@ -56,6 +60,12 @@ class CacheClass(BaseCache):
port = 6379 port = 6379
self._client = redis.Redis(host=host, port=port, db=db, password=password) self._client = redis.Redis(host=host, port=port, db=db, password=password)
def __getstate__(self):
return self._initargs
def __setstate__(self, state):
self._init(**state)
def make_key(self, key, version=None): def make_key(self, key, version=None):
""" """
Returns the utf-8 encoded bytestring of the given key as a CacheKey Returns the utf-8 encoded bytestring of the given key as a CacheKey
......
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