summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-01-27 08:21:35 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-01-27 08:21:35 +0000
commit8e8d4b5888b73e5c0b2cfc77be4c6d5898546654 (patch)
tree5f7f6537575ab01e2e4a45d05baa70ef2db5ed2b /docs
parentc6ee1f6f242a6fa5336ce7a670cebae72568ef0c (diff)
Fixed #12671 -- Added set_many(), get_many(), and clear() methods to the cache backend interface. Thanks to Jeff Balogh for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12306 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/cache.txt32
1 files changed, 29 insertions, 3 deletions
diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt
index f7b1fd5b35..84388762bf 100644
--- a/docs/topics/cache.txt
+++ b/docs/topics/cache.txt
@@ -62,7 +62,7 @@ It's used by sites such as Facebook and Wikipedia to reduce database access and
dramatically increase site performance.
Memcached is available for free at http://danga.com/memcached/ . It runs as a
-daemon and is allotted a specified amount of RAM. All it does is provide an
+daemon and is allotted a specified amount of RAM. All it does is provide a
fast interface for adding, retrieving and deleting arbitrary data in the cache.
All data is stored directly in memory, so there's no overhead of database or
filesystem usage.
@@ -522,11 +522,37 @@ actually exist in the cache (and haven't expired)::
>>> cache.get_many(['a', 'b', 'c'])
{'a': 1, 'b': 2, 'c': 3}
-Finally, you can delete keys explicitly with ``delete()``. This is an easy way
-of clearing the cache for a particular object::
+.. versionadded:: 1.2
+
+To set multiple values more efficiently, use ``set_many()`` to pass a dictionary
+of key-value pairs::
+
+ >>> cache.set_many({'a': 1, 'b': 2, 'c': 3})
+ >>> cache.get_many(['a', 'b', 'c'])
+ {'a': 1, 'b': 2, 'c': 3}
+
+Like ``cache.set()``, ``set_many()`` takes an optional ``timeout`` parameter.
+
+You can delete keys explicitly with ``delete()``. This is an easy way of
+clearing the cache for a particular object::
>>> cache.delete('a')
+.. versionadded:: 1.2
+
+If you want to clear a bunch of keys at once, ``delete_many()`` can take a list
+of keys to be cleared::
+
+ >>> cache.delete_many(['a', 'b', 'c'])
+
+.. versionadded:: 1.2
+
+Finally, if you want to delete all the keys in the cache, use
+``cache.clear()``. Be careful with this; ``clear()`` will remove *everything*
+from the cache, not just the keys set by your application. ::
+
+ >>> cache.clear()
+
.. versionadded:: 1.1
You can also increment or decrement a key that already exists using the