From 3c897e392c2213ca835388ed2fe3e9cc059850a9 Mon Sep 17 00:00:00 2001 From: Christian Pedersen Date: Mon, 10 Aug 2015 10:34:32 +0200 Subject: [PATCH 1/3] Dummy cache --- redis_cache/backends/dummy.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 redis_cache/backends/dummy.py diff --git a/redis_cache/backends/dummy.py b/redis_cache/backends/dummy.py new file mode 100644 index 00000000..991d7934 --- /dev/null +++ b/redis_cache/backends/dummy.py @@ -0,0 +1,24 @@ +from django.core.cache.backends.dummy import DummyCache + + +class RedisDummyCache(DummyCache): + def ttl(self, key): + return 0 + + def delete_pattern(self, pattern, version=None): + raise NotImplementedError + + def get_or_set(self, key, func, timeout=None): + if not callable(func): + raise Exception("Must pass in a callable") + + return func() + + def reinsert_keys(self): + raise NotImplementedError + + def persist(self, key): + return True + + def expire(self, key, timeout): + return True From ce24c7a442e986db2db00615477a7d65797a9b75 Mon Sep 17 00:00:00 2001 From: Christian Pedersen Date: Mon, 10 Aug 2015 10:34:58 +0200 Subject: [PATCH 2/3] Include Dummy cache in init --- redis_cache/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/redis_cache/__init__.py b/redis_cache/__init__.py index 5b9a18e9..fb73f2b6 100644 --- a/redis_cache/__init__.py +++ b/redis_cache/__init__.py @@ -1,2 +1,3 @@ from redis_cache.backends.single import RedisCache from redis_cache.backends.multiple import ShardedRedisCache +from redis_cache.backends.dummy import RedisDummyCache From a15b2539a1b1995eb320a6e79ed0ab89a51e4592 Mon Sep 17 00:00:00 2001 From: Christian Pedersen Date: Mon, 10 Aug 2015 21:27:17 +0200 Subject: [PATCH 3/3] Return None --- redis_cache/backends/dummy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redis_cache/backends/dummy.py b/redis_cache/backends/dummy.py index 991d7934..d307cf46 100644 --- a/redis_cache/backends/dummy.py +++ b/redis_cache/backends/dummy.py @@ -6,7 +6,7 @@ def ttl(self, key): return 0 def delete_pattern(self, pattern, version=None): - raise NotImplementedError + return None def get_or_set(self, key, func, timeout=None): if not callable(func): @@ -15,7 +15,7 @@ def get_or_set(self, key, func, timeout=None): return func() def reinsert_keys(self): - raise NotImplementedError + return None def persist(self, key): return True