mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
Fixed #20584 -- Fixed memcached's get_many() with single-use iterators.
Thanks Guyon Morée for the report.
This commit is contained in:
parent
38e904e265
commit
c9c6c16650
1
AUTHORS
1
AUTHORS
@ -168,6 +168,7 @@ answer newbie questions, and generally made Django that much better:
|
||||
Chris Jones <chris@brack3t.com>
|
||||
Chris Lamb <chris@chris-lamb.co.uk>
|
||||
Chris Streeter <chris@chrisstreeter.com>
|
||||
Christian Barcenas <christian@cbarcenas.com>
|
||||
Christian Metts
|
||||
Christian Oudard <christian.oudard@gmail.com>
|
||||
Christian Tanzer <tanzer@swing.co.at>
|
||||
|
9
django/core/cache/backends/memcached.py
vendored
9
django/core/cache/backends/memcached.py
vendored
@ -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.
|
||||
|
1
tests/cache/tests.py
vendored
1
tests/cache/tests.py
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user