mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 11:52:01 +00:00
Factor the display_recipient cache key into a function.
(imported from commit 4a80c4db6ddcf8104f45b6b068e598378e655bc0)
This commit is contained in:
@@ -221,6 +221,9 @@ def cache(func):
|
||||
def message_cache_key(message_id):
|
||||
return "message:%d" % (message_id,)
|
||||
|
||||
def display_recipient_cache_key(recipient_id):
|
||||
return "display_recipient_dict:%d" % (recipient_id,)
|
||||
|
||||
def user_profile_by_email_cache_key(email):
|
||||
# See the comment in zerver/lib/avatar.py:gravatar_hash for why we
|
||||
# are proactively encoding email addresses even though they will
|
||||
|
||||
@@ -6,7 +6,8 @@ from django.contrib.auth.models import AbstractBaseUser, UserManager, \
|
||||
PermissionsMixin
|
||||
from zerver.lib.cache import cache_with_key, update_user_profile_cache, \
|
||||
user_profile_by_id_cache_key, user_profile_by_email_cache_key, \
|
||||
update_user_presence_cache, generic_bulk_cached_fetch, cache_set
|
||||
update_user_presence_cache, generic_bulk_cached_fetch, cache_set, \
|
||||
display_recipient_cache_key
|
||||
from zerver.lib.utils import make_safe_digest, generate_random_token
|
||||
from django.db import transaction, IntegrityError
|
||||
from zerver.lib import bugdown
|
||||
@@ -35,7 +36,7 @@ def get_display_recipient(recipient):
|
||||
recipient_cache[recipient.id] = get_display_recipient_memcached(recipient)
|
||||
return recipient_cache[recipient.id]
|
||||
|
||||
@cache_with_key(lambda self: 'display_recipient_dict:%d' % (self.id,),
|
||||
@cache_with_key(lambda self: display_recipient_cache_key(self.id),
|
||||
timeout=3600*24*7)
|
||||
def get_display_recipient_memcached(recipient):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user