diff --git a/AUTHORS b/AUTHORS index 4ccdac886c..e5a22185a9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -168,6 +168,7 @@ answer newbie questions, and generally made Django that much better: Chris Jones Chris Lamb Chris Streeter + Christian Barcenas Christian Metts Christian Oudard Christian Tanzer diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py index 1c8066ba03..bb27cb53bb 100644 --- a/django/core/cache/backends/memcached.py +++ b/django/core/cache/backends/memcached.py @@ -84,12 +84,9 @@ class BaseMemcachedCache(BaseCache): self._cache.delete(key) def get_many(self, keys, version=None): - new_keys = [self.make_key(x, version=version) for x in keys] - ret = self._cache.get_multi(new_keys) - if ret: - m = dict(zip(new_keys, keys)) - return {m[k]: v for k, v in ret.items()} - return ret + key_map = {self.make_key(key, version=version): key for key in keys} + ret = self._cache.get_multi(key_map.keys()) + return {key_map[k]: v for k, v in ret.items()} def close(self, **kwargs): # Many clients don't clean up connections properly. diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 9dd7fa78e0..542ac909ad 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -312,6 +312,7 @@ class BaseCacheTests: cache.set('d', 'd') self.assertEqual(cache.get_many(['a', 'c', 'd']), {'a': 'a', 'c': 'c', 'd': 'd'}) self.assertEqual(cache.get_many(['a', 'b', 'e']), {'a': 'a', 'b': 'b'}) + self.assertEqual(cache.get_many(iter(['a', 'b', 'e'])), {'a': 'a', 'b': 'b'}) def test_delete(self): # Cache keys can be deleted