diff options
Diffstat (limited to 'django/core/cache/backends/base.py')
| -rw-r--r-- | django/core/cache/backends/base.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py index ff4223bf86..58e166d655 100644 --- a/django/core/cache/backends/base.py +++ b/django/core/cache/backends/base.py @@ -63,4 +63,11 @@ class BaseCache(object): """ return self.get(key) is not None - __contains__ = has_key + def __contains__(self, key): + """ + Returns True if the key is in the cache and has not expired. + """ + # This is a separate method, rather than just a copy of has_key(), + # so that it always has the same functionality as has_key(), even + # if a subclass overrides it. + return self.has_key(key) |
