Changeset 6774
- Timestamp:
- 11/29/07 23:30:43 (1 year ago)
- Files:
-
- django/trunk/django/core/cache/backends/base.py (modified) (5 diffs)
- django/trunk/docs/cache.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/cache/backends/base.py
r6572 r6774 17 17 def add(self, key, value, timeout=None): 18 18 """ 19 Set a value in the cache if the key does not already exist. If19 Set a value in the cache if the key does not already exist. If 20 20 timeout is given, that timeout will be used for the key; otherwise 21 21 the default cache timeout will be used. … … 25 25 def get(self, key, default=None): 26 26 """ 27 Fetch a given key from the cache. If the key does not exist, return27 Fetch a given key from the cache. If the key does not exist, return 28 28 default, which itself defaults to None. 29 29 """ … … 32 32 def set(self, key, value, timeout=None): 33 33 """ 34 Set a value in the cache. If timeout is given, that timeout will be34 Set a value in the cache. If timeout is given, that timeout will be 35 35 used for the key; otherwise the default cache timeout will be used. 36 36 """ … … 45 45 def get_many(self, keys): 46 46 """ 47 Fetch a bunch of keys from the cache. For certain backends (memcached,47 Fetch a bunch of keys from the cache. For certain backends (memcached, 48 48 pgsql) this can be *much* faster when fetching multiple values. 49 49 50 Returns a dict mapping each key in keys to its value. If the given50 Returns a dict mapping each key in keys to its value. If the given 51 51 key is missing, it will be missing from the response dict. 52 52 """ … … 65 65 66 66 __contains__ = has_key 67 django/trunk/docs/cache.txt
r6736 r6774 371 371 'has expired' 372 372 373 To add a key only if it doesn't already exist, there is an add() method. It 374 takes the same parameters as set(), but will not attempt to update the cache 375 i f the key specified is already present::373 **New in Django development version:** To add a key only if it doesn't already 374 exist, use the ``add()`` method. It takes the same parameters as ``set()``, but 375 it will not attempt to update the cache if the key specified is already present:: 376 376 377 377 >>> cache.set('add_key', 'Initial value') … … 380 380 'Initial value' 381 381 382 There's also a get_many() interface that only hits the cache once. get_many()382 There's also a ``get_many()`` interface that only hits the cache once. ``get_many()`` 383 383 returns a dictionary with all the keys you asked for that actually exist in the 384 384 cache (and haven't expired)::
