Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add documentation for get_caches function

  • Loading branch information...
commit 2315f1a2ee4e83f7514f20302cdac4782b63751a 1 parent 89136b2
Ian Clelland authored September 20, 2012

Showing 1 changed file with 16 additions and 1 deletion. Show diff stats Hide diff stats

  1. 17  docs/topics/cache.txt
17  docs/topics/cache.txt
@@ -673,12 +673,27 @@ dictionaries, lists of model objects, and so forth. (Most common Python objects
673 673
 can be pickled; refer to the Python documentation for more information about
674 674
 pickling.)
675 675
 
  676
+Accessing the cache
  677
+-------------------
  678
+
676 679
 The cache module, ``django.core.cache``, has a ``cache`` object that's
677 680
 automatically created from the ``'default'`` entry in the :setting:`CACHES`
678 681
 setting::
679 682
 
680 683
     >>> from django.core.cache import cache
681 684
 
  685
+If you have multiple caches defined in :setting:`CACHES`, then you can use
  686
+:func:`django.core.cache.get_cache` to retrieve a cache object for any key::
  687
+
  688
+    >>> from django.core.cache import get_cache
  689
+    >>> cache = get_cache('alternate')
  690
+
  691
+If the named key does not exist, :exc:`InvalidCacheBackendError` will be raised.
  692
+
  693
+
  694
+Basic usage
  695
+-----------
  696
+
682 697
 The basic interface is ``set(key, value, timeout)`` and ``get(key)``::
683 698
 
684 699
     >>> cache.set('my_key', 'hello, world!', 30)
@@ -686,7 +701,7 @@ The basic interface is ``set(key, value, timeout)`` and ``get(key)``::
686 701
     'hello, world!'
687 702
 
688 703
 The ``timeout`` argument is optional and defaults to the ``timeout``
689  
-argument of the ``'default'`` backend in :setting:`CACHES` setting
  704
+argument of the appropriate backend in the :setting:`CACHES` setting
690 705
 (explained above). It's the number of seconds the value should be stored
691 706
 in the cache.
692 707
 

0 notes on commit 2315f1a

Please sign in to comment.
Something went wrong with that request. Please try again.