Extract data from cache in tornado_callbacks with cache_get_many

This reduces the number of memcached calls we make in our time-
slice-limited tornado event handler.

(imported from commit 8903ce4ac754ba82d57e04d1b0356be7533edee2)
This commit is contained in:
Leo Franchi
2013-09-13 16:35:27 -04:00
parent 5eaeddea12
commit 7bb96bd36b
2 changed files with 69 additions and 9 deletions

View File

@@ -233,6 +233,9 @@ def user_profile_by_email_cache_key(email):
def user_profile_by_id_cache_key(user_profile_id):
return "user_profile_by_id:%s" % (user_profile_id,)
def cache_save_user_profile(user_profile):
cache_set(user_profile_by_id_cache_key(user_profile.id), user_profile, timeout=3600*24*7)
# Called by models.py to flush the user_profile cache whenever we save
# a user_profile object
def update_user_profile_cache(sender, **kwargs):