Ticket #8414: cahche.patch
File cahche.patch, 1.8 KB (added by , 16 years ago) |
---|
-
core/cache/backends/base.py
13 13 except (ValueError, TypeError): 14 14 timeout = 300 15 15 self.default_timeout = timeout 16 self._key_prefix = params.get('key_prefix', '') 16 17 17 18 def add(self, key, value, timeout=None): 18 19 """ -
core/cache/backends/memcached.py
17 17 self._cache = memcache.Client(server.split(';')) 18 18 19 19 def add(self, key, value, timeout=0): 20 return self._cache.add( key.encode('ascii', 'ignore'), value, timeout or self.default_timeout)20 return self._cache.add('%s%s' % (self._key_prefix, key.encode('ascii', 'ignore')), value, timeout or self.default_timeout) 21 21 22 22 def get(self, key, default=None): 23 val = self._cache.get(smart_str( key))23 val = self._cache.get(smart_str('%s%s' % (self._key_prefix, key))) 24 24 if val is None: 25 25 return default 26 26 else: … … 32 32 def set(self, key, value, timeout=0): 33 33 if isinstance(value, unicode): 34 34 value = value.encode('utf-8') 35 self._cache.set(smart_str( key), value, timeout or self.default_timeout)35 self._cache.set(smart_str('%s%s' % (self._key_prefix, key)), value, timeout or self.default_timeout) 36 36 37 37 def delete(self, key): 38 self._cache.delete(smart_str( key))38 self._cache.delete(smart_str('%s%s' % (self._key_prefix, key))) 39 39 40 40 def get_many(self, keys): 41 41 return self._cache.get_multi(map(smart_str,keys))