Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added 'dummy' cache backend

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1815 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6cca806943790a586a059bd2dacdf5d54e5f601d 1 parent 839bcfe
Adrian Holovaty authored January 03, 2006
37  django/core/cache.py
@@ -32,6 +32,9 @@
32 32
     locmem:///                      A more sophisticaed local memory cache;
33 33
                                     this is multi-process- and thread-safe.
34 34
 
  35
+    dummy:///                       Doesn't actually cache. For use in test
  36
+                                    environments.
  37
+
35 38
 All caches may take arguments; these are given in query-string style.  Valid
36 39
 arguments are:
37 40
 
@@ -275,6 +278,29 @@ def delete(self, key):
275 278
         finally:
276 279
             self._lock.writer_leaves()
277 280
 
  281
+###############
  282
+# Dummy cache #
  283
+###############
  284
+
  285
+class _DummyCache(_Cache):
  286
+    def __init__(self, *args, **kwargs):
  287
+        pass
  288
+
  289
+    def get(self, *args, **kwargs):
  290
+        pass
  291
+
  292
+    def set(self, *args, **kwargs):
  293
+        pass
  294
+
  295
+    def delete(self, *args, **kwargs):
  296
+        pass
  297
+
  298
+    def get_many(self, *args, **kwargs):
  299
+        pass
  300
+
  301
+    def has_key(self, *args, **kwargs):
  302
+        return False
  303
+
278 304
 ####################
279 305
 # File-based cache #
280 306
 ####################
@@ -443,11 +469,12 @@ def _cull(self, cursor, now):
443 469
 from cgi import parse_qsl
444 470
 
445 471
 _BACKENDS = {
446  
-    'memcached' : _MemcachedCache,
447  
-    'simple'    : _SimpleCache,
448  
-    'locmem'    : _LocMemCache,
449  
-    'file'      : _FileCache,
450  
-    'db'        : _DBCache,
  472
+    'memcached': _MemcachedCache,
  473
+    'simple': _SimpleCache,
  474
+    'locmem': _LocMemCache,
  475
+    'file': _FileCache,
  476
+    'db': _DBCache,
  477
+    'dummy': _DummyCache,
451 478
 }
452 479
 
453 480
 def get_cache(backend_uri):
6  docs/cache.txt
@@ -47,6 +47,12 @@ Examples:
47 47
 
48 48
     locmem:///                      A more sophisticated local memory cache;
49 49
                                     this is multi-process- and thread-safe.
  50
+
  51
+    dummy:///                       **New in Django development version.**
  52
+                                    Doesn't actually cache; just implements the
  53
+                                    cache backend interface and doesn't do
  54
+                                    anything. This is an easy way to turn off
  55
+                                    caching for a test environment.
50 56
     ==============================  ===========================================
51 57
 
52 58
 All caches may take arguments -- they're given in query-string style.  Valid

0 notes on commit 6cca806

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