Ticket #25840: get_or_set_dummycache.path

File get_or_set_dummycache.path, 782 bytes (added by Oleksiy Ivanenko, 9 years ago)
Line 
1diff --git django/core/cache/backends/dummy.py django/core/cache/backends/dummy.py
2index d1aea0a..6608b11 100644
3--- django/core/cache/backends/dummy.py
4+++ django/core/cache/backends/dummy.py
5@@ -28,6 +28,15 @@ class DummyCache(BaseCache):
6 def get_many(self, keys, version=None):
7 return {}
8
9+ def get_or_set(self, key, default=None, timeout=DEFAULT_TIMEOUT, version=None):
10+ if default is None:
11+ raise ValueError('You need to specify a value.')
12+ key = self.make_key(key, version=version)
13+ self.validate_key(key)
14+ if callable(default):
15+ default = default()
16+ return default
17+
18 def has_key(self, key, version=None):
19 key = self.make_key(key, version=version)
20 self.validate_key(key)
Back to Top