From dc48b23f803a35f88d1017ddd6be1f237d0a938d Mon Sep 17 00:00:00 2001 From: Dario Varotto Date: Thu, 29 Sep 2016 12:58:39 +0200 Subject: [PATCH 1/3] Handle invalidating a namespace without keys --- redis_cache/rediscache.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/redis_cache/rediscache.py b/redis_cache/rediscache.py index f951bd8..77ec799 100644 --- a/redis_cache/rediscache.py +++ b/redis_cache/rediscache.py @@ -168,9 +168,10 @@ def expire_namespace(self, namespace): """ namespace = self.namespace_key(namespace) all_members = list(self.connection.keys(namespace)) - with self.connection.pipeline() as pipe: - pipe.delete(*all_members) - pipe.execute() + if all_members: + with self.connection.pipeline() as pipe: + pipe.delete(*all_members) + pipe.execute() return len(self), len(all_members) From a0b0f38ed30870adbbe958e4adc152f3b7487db1 Mon Sep 17 00:00:00 2001 From: Dario Varotto Date: Thu, 29 Sep 2016 13:09:36 +0200 Subject: [PATCH 2/3] cache_it_json was ignoring the namespace --- redis_cache/rediscache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis_cache/rediscache.py b/redis_cache/rediscache.py index 77ec799..76a3017 100644 --- a/redis_cache/rediscache.py +++ b/redis_cache/rediscache.py @@ -376,7 +376,7 @@ def cache_it_json(limit=10000, expire=DEFAULT_EXPIRY, cache=None, namespace=None :return: decorated function """ return cache_it(limit=limit, expire=expire, use_json=True, - cache=cache, namespace=None) + cache=cache, namespace=namespace) def to_unicode(obj, encoding='utf-8'): From 6fa67ef0c1b677a21cd9920ee12fc15d62fb4bb6 Mon Sep 17 00:00:00 2001 From: Dario Varotto Date: Thu, 29 Sep 2016 13:54:09 +0200 Subject: [PATCH 3/3] When nothing to delete just return None --- redis_cache/rediscache.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/redis_cache/rediscache.py b/redis_cache/rediscache.py index 76a3017..ce17889 100644 --- a/redis_cache/rediscache.py +++ b/redis_cache/rediscache.py @@ -172,8 +172,7 @@ def expire_namespace(self, namespace): with self.connection.pipeline() as pipe: pipe.delete(*all_members) pipe.execute() - - return len(self), len(all_members) + return len(self), len(all_members) def isexpired(self, key): """