Fix use of invalid hash keys with memcached.

Email addresses can contain characters that are not valid for
memcached cache keys.

(imported from commit d7cfd6d5292e4fc8f4e2b19f2c01a4097d878f1b)
This commit is contained in:
Tim Abbott
2013-03-13 14:49:32 -04:00
parent c098520bbd
commit 0a9a553b5f

View File

@@ -1,4 +1,5 @@
from functools import wraps
import hashlib
from django.core.cache import cache as djcache
from django.core.cache import get_cache
@@ -55,7 +56,7 @@ def message_cache_key(message_id):
return "message:%d" % (message_id,)
def userprofile_by_email_cache_key(email):
return 'tornado_user_profile_by_email:%s' % (email,)
return 'tornado_user_profile_by_email:%s' % (hashlib.sha1(email).hexdigest(),)
def userprofile_by_user_cache_key(user_id):
return 'tornado_user_profile_by_user:%d' % (user_id,)