app/django/core/cache/backends/base.py
changeset 323 ff1a9aa48cfd
parent 54 03e267d67478
equal deleted inserted replaced
322:6641e941ef1e 323:ff1a9aa48cfd
    17     def add(self, key, value, timeout=None):
    17     def add(self, key, value, timeout=None):
    18         """
    18         """
    19         Set a value in the cache if the key does not already exist. If
    19         Set a value in the cache if the key does not already exist. If
    20         timeout is given, that timeout will be used for the key; otherwise
    20         timeout is given, that timeout will be used for the key; otherwise
    21         the default cache timeout will be used.
    21         the default cache timeout will be used.
       
    22 
       
    23         Returns True if the value was stored, False otherwise.
    22         """
    24         """
    23         raise NotImplementedError
    25         raise NotImplementedError
    24 
    26 
    25     def get(self, key, default=None):
    27     def get(self, key, default=None):
    26         """
    28         """
    61         """
    63         """
    62         Returns True if the key is in the cache and has not expired.
    64         Returns True if the key is in the cache and has not expired.
    63         """
    65         """
    64         return self.get(key) is not None
    66         return self.get(key) is not None
    65 
    67 
    66     __contains__ = has_key
    68     def __contains__(self, key):
       
    69         """
       
    70         Returns True if the key is in the cache and has not expired.
       
    71         """
       
    72         # This is a separate method, rather than just a copy of has_key(),
       
    73         # so that it always has the same functionality as has_key(), even
       
    74         # if a subclass overrides it.
       
    75         return self.has_key(key)