Created
April 23, 2014 09:41
-
-
Save spikeekips/11208865 to your computer and use it in GitHub Desktop.
persistant `LocMemCache` without checking expiry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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