Use bulk requests for updating memcached in get_old_messages.

Otherwise we end up doing 1000 requests to memcached, which can be
quite expensive.

(imported from commit be247f63b5fb88c6f4a45326261b66ea67fe1028)
This commit is contained in:
Tim Abbott
2013-04-25 14:41:54 -04:00
parent 3e1ec5d7c9
commit 7c001822f2
3 changed files with 22 additions and 7 deletions

View File

@@ -74,6 +74,13 @@ def cache_get_many(keys, cache_name=None):
cache_backend = get_cache(cache_name)
return cache_backend.get_many(keys)
def cache_set_many(items, cache_name=None):
if cache_name is None:
cache_backend = djcache
else:
cache_backend = get_cache(cache_name)
return cache_backend.set_many(items)
def cache(func):
"""Decorator which applies Django caching to a function.