mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +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 Jones <chris@brack3t.com>
|
||||||
Chris Lamb <chris@chris-lamb.co.uk>
|
Chris Lamb <chris@chris-lamb.co.uk>
|
||||||
Chris Streeter <chris@chrisstreeter.com>
|
Chris Streeter <chris@chrisstreeter.com>
|
||||||
|
Christian Barcenas <christian@cbarcenas.com>
|
||||||
Christian Metts
|
Christian Metts
|
||||||
Christian Oudard <christian.oudard@gmail.com>
|
Christian Oudard <christian.oudard@gmail.com>
|
||||||
Christian Tanzer <tanzer@swing.co.at>
|
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)
|
self._cache.delete(key)
|
||||||
|
|
||||||
def get_many(self, keys, version=None):
|
def get_many(self, keys, version=None):
|
||||||
new_keys = [self.make_key(x, version=version) for x in keys]
|
key_map = {self.make_key(key, version=version): key for key in keys}
|
||||||
ret = self._cache.get_multi(new_keys)
|
ret = self._cache.get_multi(key_map.keys())
|
||||||
if ret:
|
return {key_map[k]: v for k, v in ret.items()}
|
||||||
m = dict(zip(new_keys, keys))
|
|
||||||
return {m[k]: v for k, v in ret.items()}
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def close(self, **kwargs):
|
def close(self, **kwargs):
|
||||||
# Many clients don't clean up connections properly.
|
# 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')
|
cache.set('d', 'd')
|
||||||
self.assertEqual(cache.get_many(['a', 'c', 'd']), {'a': 'a', 'c': 'c', '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(['a', 'b', 'e']), {'a': 'a', 'b': 'b'})
|
||||||
|
self.assertEqual(cache.get_many(iter(['a', 'b', 'e'])), {'a': 'a', 'b': 'b'})
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
# Cache keys can be deleted
|
# Cache keys can be deleted
|
||||||
|
Loading…
Reference in New Issue
Block a user