Ticket #21200: locmem_django_issue_21200.patch

File locmem_django_issue_21200.patch, 2.0 KB (added by Thomas C, 11 years ago)
  • django/core/cache/backends/locmem.py

    diff --git a/django/core/cache/backends/locmem.py b/django/core/cache/backends/locmem.py
    index cab690b..73b02a5 100644
    a b class LocMemCache(BaseCache):  
    2727    def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
    2828        key = self.make_key(key, version=version)
    2929        self.validate_key(key)
    30         try:
    31             pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
    32         except pickle.PickleError:
    33             return False
     30        pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
    3431        with self._lock.writer():
    3532            exp = self._expire_info.get(key)
    3633            if exp is None or exp <= time.time():
    class LocMemCache(BaseCache):  
    6966    def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
    7067        key = self.make_key(key, version=version)
    7168        self.validate_key(key)
    72         try:
    73             pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
    74         except pickle.PickleError:
    75             pass
    76         else:
    77             with self._lock.writer():
    78                 self._set(key, pickled, timeout)
     69        pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
     70        with self._lock.writer():
     71            self._set(key, pickled, timeout)
    7972
    8073    def incr(self, key, delta=1, version=None):
    8174        value = self.get(key, version=version)
    class LocMemCache(BaseCache):  
    8376            raise ValueError("Key '%s' not found" % key)
    8477        new_value = value + delta
    8578        key = self.make_key(key, version=version)
    86         try:
    87             pickled = pickle.dumps(new_value, pickle.HIGHEST_PROTOCOL)
    88         except pickle.PickleError:
    89             pass
    90         else:
    91             with self._lock.writer():
    92                 self._cache[key] = pickled
     79        pickled = pickle.dumps(new_value, pickle.HIGHEST_PROTOCOL)
     80        with self._lock.writer():
     81            self._cache[key] = pickled
    9382        return new_value
    9483
    9584    def has_key(self, key, version=None):
Back to Top