summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authortsauerwein <tobias.sauerwein@camptocamp.com>2016-09-07 12:16:46 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-06-23 15:31:47 -0400
commit2f82d8f3c09a5b0379648e11bc5a7f504e502e9a (patch)
treeb99a49982d8d10ec86e902010a6944ef04be51e2 /tests
parent14510be1a67fbee6f57603ecadf610750b7d777b (diff)
downloaddogpile-cache-2f82d8f3c09a5b0379648e11bc5a7f504e502e9a.tar.gz
Do not store empty dict when using Region.get_or_create_multi with should_cache_fn
If `Region.get_or_create_multi` is used with a `should_cache` function and no value of the current set should be cached, do not try to store the empty dict in the backend. It's unnecessary and also breaks on some backends such as Redis. Change-Id: Ib7a48d0d7b2f6569e09008f4603f8a355bf9396a Pull-request: https://bitbucket.org/zzzeek/dogpile.cache/pull-requests/58
Diffstat (limited to 'tests')
-rw-r--r--tests/cache/_fixtures.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/cache/_fixtures.py b/tests/cache/_fixtures.py
index 5340f61..fd8248a 100644
--- a/tests/cache/_fixtures.py
+++ b/tests/cache/_fixtures.py
@@ -118,6 +118,13 @@ class _GenericBackendTest(_GenericBackendFixture, TestCase):
values = reg.get_or_create_multi([], lambda: 0)
eq_(values, [])
+ def test_region_get_or_create_multi_w_should_cache_none(self):
+ reg = self._region()
+ values = reg.get_or_create_multi(
+ ['key1', 'key2', 'key3'], lambda *k: [None, None, None],
+ should_cache_fn=lambda v: v is not None)
+ eq_(values, [None, None, None])
+
def test_region_get_multiple_values(self):
reg = self._region()
key1 = 'value1'