Don't include cache in serialization of backend

Fixes #227
This commit is contained in:
Matthew Tretter 2013-06-20 09:17:12 -04:00
parent ada883c99f
commit 637af70921

View file

@ -1,4 +1,5 @@
from ..utils import get_singleton, sanitize_cache_key
from copy import copy
from django.core.cache import get_cache
from django.core.exceptions import ImproperlyConfigured
@ -76,6 +77,13 @@ class CachedFileBackend(object):
else:
self.cache.set(key, state)
def __getstate__(self):
state = copy(self.__dict__)
# Don't include the cache when pickling. It'll be reconstituted based
# on the settings.
state.pop('_cache', None)
return state
def exists(self, file):
return self.get_state(file) is CacheFileState.EXISTS