1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Added a return value to the add() method for caches. It's now possible to tell

if a call to add() ended up storing something in the cache.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8278 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick
2008-08-10 03:52:21 +00:00
parent 38dc472796
commit f6670e1341
8 changed files with 20 additions and 9 deletions

View File

@@ -410,9 +410,13 @@ it will not attempt to update the cache if the key specified is already present:
>>> cache.get('add_key')
'Initial value'
There's also a ``get_many()`` interface that only hits the cache once. ``get_many()``
returns a dictionary with all the keys you asked for that actually exist in the
cache (and haven't expired)::
If you need to know whether ``add()`` stored a value in the cache, you can
check the return value. It will return ``True`` if the value was stored,
``False`` otherwise.
There's also a ``get_many()`` interface that only hits the cache once.
``get_many()`` returns a dictionary with all the keys you asked for that
actually exist in the cache (and haven't expired)::
>>> cache.set('a', 1)
>>> cache.set('b', 2)