Commits

Wichert Akkerman committed 977404b

Add dummy cache backend

Comments (0)

Files changed (3)

 .. automodule:: dogpile.cache.proxy
     :members:
 
+.. automodule:: dogpile.cache.dummy
+    :members:
 
 Plugins
 ========

dogpile/cache/backends/__init__.py

 from dogpile.cache.region import register_backend
 
+register_backend("dogpile.cache.dummy", "dogpile.cache.backends.dummy", "DummyBackend")
 register_backend("dogpile.cache.dbm", "dogpile.cache.backends.file", "DBMBackend")
 register_backend("dogpile.cache.pylibmc", "dogpile.cache.backends.memcached", "PylibmcBackend")
 register_backend("dogpile.cache.bmemcached", "dogpile.cache.backends.memcached", "BMemcachedBackend")

dogpile/cache/backends/dummy.py

+"""
+Dummy Backend
+-------------
+
+The dummy backend does not do any cachingn at all. It is inteded to be used
+to test behaviour without caching.
+"""
+
+from dogpile.cache.api import CacheBackend, NO_VALUE
+
+
+__all__ = ['DummyBackend']
+
+
+class DummyLock(object):  # pragma NO COVERAGE
+    def acquire(self):
+        pass
+
+    def release(self):
+        pass
+
+
+class DummyBackend(CacheBackend):  # pragma NO COVERAGE
+    def __init__(self, arguments):
+        pass
+
+    def get_mutex(self, key):
+        return DummyLock()
+
+    def get(self, key):
+        return NO_VALUE
+
+    def get_multiple(self, keys):
+        return [NO_VALUE for k in keys]
+
+    def set(self, key, value):
+        pass
+
+    def set_multiple(self, mapping):
+        pass
+
+    def delete(self, key):
+        pass
+
+    def delete_multiple(self, keys):
+        pass