web/lib/django/core/cache/backends/base.py
changeset 29 cc9b7e14412b
parent 0 0d40e90630ef
--- a/web/lib/django/core/cache/backends/base.py	Wed May 19 17:43:59 2010 +0200
+++ b/web/lib/django/core/cache/backends/base.py	Tue May 25 02:43:45 2010 +0200
@@ -71,7 +71,7 @@
         ValueError exception.
         """
         if key not in self:
-            raise ValueError, "Key '%s' not found" % key
+            raise ValueError("Key '%s' not found" % key)
         new_value = self.get(key) + delta
         self.set(key, new_value)
         return new_value
@@ -91,3 +91,28 @@
         # so that it always has the same functionality as has_key(), even
         # if a subclass overrides it.
         return self.has_key(key)
+
+    def set_many(self, data, timeout=None):
+        """
+        Set a bunch of values in the cache at once from a dict of key/value
+        pairs.  For certain backends (memcached), this is much more efficient
+        than calling set() multiple times.
+
+        If timeout is given, that timeout will be used for the key; otherwise
+        the default cache timeout will be used.
+        """
+        for key, value in data.items():
+            self.set(key, value, timeout)
+
+    def delete_many(self, keys):
+        """
+        Set a bunch of values in the cache at once.  For certain backends
+        (memcached), this is much more efficient than calling delete() multiple
+        times.
+        """
+        for key in keys:
+            self.delete(key)
+
+    def clear(self):
+        """Remove *all* values from the cache at once."""
+        raise NotImplementedError