Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Edited docs and docstring changes from [6572] (new cache add() method)

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6774 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9e762f44078803f07f43b95cf8bdb0c1893cf7fa 1 parent 7ea174e
Adrian Holovaty authored November 30, 2007
11  django/core/cache/backends/base.py
@@ -16,7 +16,7 @@ def __init__(self, params):
16 16
 
17 17
     def add(self, key, value, timeout=None):
18 18
         """
19  
-        Set a value in the cache if the key does not already exist.  If
  19
+        Set a value in the cache if the key does not already exist. If
20 20
         timeout is given, that timeout will be used for the key; otherwise
21 21
         the default cache timeout will be used.
22 22
         """
@@ -24,14 +24,14 @@ def add(self, key, value, timeout=None):
24 24
 
25 25
     def get(self, key, default=None):
26 26
         """
27  
-        Fetch a given key from the cache.  If the key does not exist, return
  27
+        Fetch a given key from the cache. If the key does not exist, return
28 28
         default, which itself defaults to None.
29 29
         """
30 30
         raise NotImplementedError
31 31
 
32 32
     def set(self, key, value, timeout=None):
33 33
         """
34  
-        Set a value in the cache.  If timeout is given, that timeout will be
  34
+        Set a value in the cache. If timeout is given, that timeout will be
35 35
         used for the key; otherwise the default cache timeout will be used.
36 36
         """
37 37
         raise NotImplementedError
@@ -44,10 +44,10 @@ def delete(self, key):
44 44
 
45 45
     def get_many(self, keys):
46 46
         """
47  
-        Fetch a bunch of keys from the cache.  For certain backends (memcached,
  47
+        Fetch a bunch of keys from the cache. For certain backends (memcached,
48 48
         pgsql) this can be *much* faster when fetching multiple values.
49 49
 
50  
-        Returns a dict mapping each key in keys to its value.  If the given
  50
+        Returns a dict mapping each key in keys to its value. If the given
51 51
         key is missing, it will be missing from the response dict.
52 52
         """
53 53
         d = {}
@@ -64,4 +64,3 @@ def has_key(self, key):
64 64
         return self.get(key) is not None
65 65
 
66 66
     __contains__ = has_key
67  
-
8  docs/cache.txt
@@ -370,16 +370,16 @@ get() can take a ``default`` argument::
370 370
     >>> cache.get('my_key', 'has expired')
371 371
     'has expired'
372 372
 
373  
-To add a key only if it doesn't already exist, there is an add() method.  It
374  
-takes the same parameters as set(), but will not attempt to update the cache
375  
-if the key specified is already present::
  373
+**New in Django development version:** To add a key only if it doesn't already
  374
+exist, use the ``add()`` method. It takes the same parameters as ``set()``, but
  375
+it will not attempt to update the cache if the key specified is already present::
376 376
 
377 377
     >>> cache.set('add_key', 'Initial value')
378 378
     >>> cache.add('add_key', 'New value')
379 379
     >>> cache.get('add_key')
380 380
     'Initial value'
381 381
 
382  
-There's also a get_many() interface that only hits the cache once. get_many()
  382
+There's also a ``get_many()`` interface that only hits the cache once. ``get_many()``
383 383
 returns a dictionary with all the keys you asked for that actually exist in the
384 384
 cache (and haven't expired)::
385 385
 

0 notes on commit 9e762f4

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