summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-01-03 23:41:31 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-01-03 23:41:31 +0000
commit6cca806943790a586a059bd2dacdf5d54e5f601d (patch)
tree4d29003a24e5f09ee4f0a141141597a938a72bb6
parent839bcfe33059e43c382bdc5204cd08fa185a0bd6 (diff)
Added 'dummy' cache backend
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1815 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/cache.py37
-rw-r--r--docs/cache.txt6
2 files changed, 38 insertions, 5 deletions
diff --git a/django/core/cache.py b/django/core/cache.py
index f237da7141..14df9ddb1d 100644
--- a/django/core/cache.py
+++ b/django/core/cache.py
@@ -32,6 +32,9 @@ The CACHE_BACKEND setting is a quasi-URI; examples are:
locmem:/// A more sophisticaed local memory cache;
this is multi-process- and thread-safe.
+ dummy:/// Doesn't actually cache. For use in test
+ environments.
+
All caches may take arguments; these are given in query-string style. Valid
arguments are:
@@ -275,6 +278,29 @@ class _LocMemCache(_SimpleCache):
finally:
self._lock.writer_leaves()
+###############
+# Dummy cache #
+###############
+
+class _DummyCache(_Cache):
+ def __init__(self, *args, **kwargs):
+ pass
+
+ def get(self, *args, **kwargs):
+ pass
+
+ def set(self, *args, **kwargs):
+ pass
+
+ def delete(self, *args, **kwargs):
+ pass
+
+ def get_many(self, *args, **kwargs):
+ pass
+
+ def has_key(self, *args, **kwargs):
+ return False
+
####################
# File-based cache #
####################
@@ -443,11 +469,12 @@ class _DBCache(_Cache):
from cgi import parse_qsl
_BACKENDS = {
- 'memcached' : _MemcachedCache,
- 'simple' : _SimpleCache,
- 'locmem' : _LocMemCache,
- 'file' : _FileCache,
- 'db' : _DBCache,
+ 'memcached': _MemcachedCache,
+ 'simple': _SimpleCache,
+ 'locmem': _LocMemCache,
+ 'file': _FileCache,
+ 'db': _DBCache,
+ 'dummy': _DummyCache,
}
def get_cache(backend_uri):
diff --git a/docs/cache.txt b/docs/cache.txt
index 8f81514e66..09e201a202 100644
--- a/docs/cache.txt
+++ b/docs/cache.txt
@@ -47,6 +47,12 @@ Examples:
locmem:/// A more sophisticated local memory cache;
this is multi-process- and thread-safe.
+
+ dummy:/// **New in Django development version.**
+ Doesn't actually cache; just implements the
+ cache backend interface and doesn't do
+ anything. This is an easy way to turn off
+ caching for a test environment.
============================== ===========================================
All caches may take arguments -- they're given in query-string style. Valid