diff options
author | Eric Hanchrow <ehanchrow@ine.com> | 2014-01-06 11:31:08 -0800 |
---|---|---|
committer | Eric Hanchrow <ehanchrow@ine.com> | 2014-01-06 11:31:08 -0800 |
commit | 5dc5e1ab1404fbb35f33bb6a7fe7ac9505eb5fba (patch) | |
tree | a23a7959983112044e036df61bca8ffdf7446297 | |
parent | ead71f38f2048d759202b61b090894ba5b6309f9 (diff) | |
download | dogpile-cache-5dc5e1ab1404fbb35f33bb6a7fe7ac9505eb5fba.tar.gz |
Apply the new "get" attribute for :meth:`cache_multi_on_arguments` ...
... as well as :meth:`cache_on_arguments`.
-rw-r--r-- | dogpile/cache/region.py | 5 | ||||
-rw-r--r-- | tests/cache/test_decorator.py | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/dogpile/cache/region.py b/dogpile/cache/region.py index 04be3ed..00228ca 100644 --- a/dogpile/cache/region.py +++ b/dogpile/cache/region.py @@ -1192,6 +1192,10 @@ class CacheRegion(object): in zip(gen_keys, keys)) ) + def get(*arg): + keys = key_generator(*arg) + return self.get_multi(keys) + def refresh(*arg): keys = key_generator(*arg) values = fn(*arg) @@ -1209,6 +1213,7 @@ class CacheRegion(object): decorate.set = set_ decorate.invalidate = invalidate decorate.refresh = refresh + decorate.get = get return decorate return decorator diff --git a/tests/cache/test_decorator.py b/tests/cache/test_decorator.py index 00f7cbd..c16bdc3 100644 --- a/tests/cache/test_decorator.py +++ b/tests/cache/test_decorator.py @@ -107,6 +107,14 @@ class DecoratorTest(_GenericBackendFixture, TestCase): eq_(go(2, 1), (2, 2, 1)) eq_(go.get(2, 1), (2, 2, 1)) + def test_explicit_get_multi(self): + go = self._multi_fixture(expiration_time=1) + eq_(go(1, 2), ['1 1', '1 2']) + eq_(go.get(1, 2), ['1 1', '1 2']) + eq_(go.get(3, 1), [NO_VALUE, '1 1']) + eq_(go(3, 1), ['2 3', '1 1']) + eq_(go.get(3, 1), ['2 3', '1 1']) + def test_explicit_set_multi(self): go = self._multi_fixture(expiration_time=1) eq_(go(1, 2), ['1 1', '1 2']) |