Skip to content

Instantly share code, notes, and snippets.

@spikeekips
Created April 23, 2014 09:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save spikeekips/11208865 to your computer and use it in GitHub Desktop.
persistant `LocMemCache` without checking expiry.
import sys
from django.core.cache.backends.locmem import LocMemCache as LocMemCache_django
class LocMemCache (LocMemCache_django, ) :
def __init__ (self, name, params, ) :
params['max_entries'] = sys.maxint
super(LocMemCache, self).__init__(name, params, )
def has_key(self, key, version=None):
key = self.make_key(key, version=version)
self.validate_key(key)
with self._lock.reader() :
return self._cache.has_key(key, )
with self._lock.writer():
try:
del self._cache[key]
del self._expire_info[key]
except KeyError:
pass
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment