summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2012-09-21 04:07:26 -0700
committerTim Graham <timograham@gmail.com>2012-09-21 04:07:26 -0700
commite758ecc628bb1d8960d0a59a140a43d7103e89e4 (patch)
treec571e472282b4442c5ecdbd17373e385ffe694fc
parent837425b425c2d58596f3ed04a7ed79541279ee7e (diff)
parent2315f1a2ee4e83f7514f20302cdac4782b63751a (diff)
Merge pull request #386 from clelland/ticket_15269
Fixed #15269 - Added documentation for get_caches function
-rw-r--r--docs/topics/cache.txt17
1 files changed, 16 insertions, 1 deletions
diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt
index 77d2de7fe0..e80ac85bd8 100644
--- a/docs/topics/cache.txt
+++ b/docs/topics/cache.txt
@@ -663,12 +663,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)
@@ -676,7 +691,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.