Avoid passing a generator expression to cache.get_many()
Generator expressions passed to the memcached backend's implementation of get_many() are exhausted prematurely. This results in KeyErrors when the backend tries to map keys returned by memcached back to keys passed by application code. See https://github.com/django/django/blob/stable/1.8.x/django/core/cache/backends/memcached.py/#L99. LEARNER-382
This commit is contained in:
@@ -53,7 +53,7 @@ def get_programs(uuid=None):
|
||||
if not uuids:
|
||||
logger.warning('Program UUIDs are not cached.')
|
||||
|
||||
programs = cache.get_many(PROGRAM_CACHE_KEY_TPL.format(uuid=uuid) for uuid in uuids)
|
||||
programs = cache.get_many([PROGRAM_CACHE_KEY_TPL.format(uuid=uuid) for uuid in uuids])
|
||||
programs = list(programs.values())
|
||||
|
||||
missing_uuids = set(uuids) - set(program['uuid'] for program in programs)
|
||||
|
||||
Reference in New Issue
Block a user