diff options
| author | Ian Clelland <ian@fullfactor.com> | 2012-09-20 12:07:34 -0700 |
|---|---|---|
| committer | Ian Clelland <ian@fullfactor.com> | 2012-09-20 12:07:34 -0700 |
| commit | 2315f1a2ee4e83f7514f20302cdac4782b63751a (patch) | |
| tree | 03571914370e018c0b23df3ea198e0fe66fb3536 | |
| parent | 89136b2725db3cb774ae4b39849684ae8f3847aa (diff) | |
Add documentation for get_caches function
| -rw-r--r-- | docs/topics/cache.txt | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt index f13238e342..f84c20a952 100644 --- a/docs/topics/cache.txt +++ b/docs/topics/cache.txt @@ -673,12 +673,27 @@ dictionaries, lists of model objects, and so forth. (Most common Python objects can be pickled; refer to the Python documentation for more information about pickling.) +Accessing the cache +------------------- + The cache module, ``django.core.cache``, has a ``cache`` object that's automatically created from the ``'default'`` entry in the :setting:`CACHES` setting:: >>> from django.core.cache import cache +If you have multiple caches defined in :setting:`CACHES`, then you can use +:func:`django.core.cache.get_cache` to retrieve a cache object for any key:: + + >>> from django.core.cache import get_cache + >>> cache = get_cache('alternate') + +If the named key does not exist, :exc:`InvalidCacheBackendError` will be raised. + + +Basic usage +----------- + The basic interface is ``set(key, value, timeout)`` and ``get(key)``:: >>> cache.set('my_key', 'hello, world!', 30) @@ -686,7 +701,7 @@ The basic interface is ``set(key, value, timeout)`` and ``get(key)``:: 'hello, world!' The ``timeout`` argument is optional and defaults to the ``timeout`` -argument of the ``'default'`` backend in :setting:`CACHES` setting +argument of the appropriate backend in the :setting:`CACHES` setting (explained above). It's the number of seconds the value should be stored in the cache. |
