Retrieve message objects from memcached in a bulk request.

On my laptop, this saves about 80 milliseconds per 1000 messages
requested via get_old_messages queries.  Since we only have one
memcached process and it does not run with special priority, this
might have significant impact on load during server restarts.

(imported from commit 06ad13f32f4a6d87a0664c96297ef9843f410ac5)
This commit is contained in:
Tim Abbott
2013-04-22 10:29:57 -04:00
parent 66b3c1fbff
commit 9b8f0fab0f
3 changed files with 44 additions and 18 deletions

View File

@@ -67,6 +67,13 @@ def cache_with_key(keyfunc, cache_name=None, timeout=None):
return decorator
def cache_get_many(keys, cache_name=None):
if cache_name is None:
cache_backend = djcache
else:
cache_backend = get_cache(cache_name)
return cache_backend.get_many(keys)
def cache(func):
"""Decorator which applies Django caching to a function.