mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
send_message: Use a memcached for the UserProfile-by-id cache.
This cache should save 2 database queries whenever we send a private message. However, previously it was per-process (which meant it was mostly useless) and also buggy (it never stored anything in the cache, so that it was completely useless). Switching this to our standard memcached setup will address both problems. (imported from commit 1d807f30704bccf28de33a80523488aedc58a9be)
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
from zephyr.models import Message, UserProfile
|
||||
from zephyr.lib.cache import cache_with_key, djcache, message_cache_key, \
|
||||
userprofile_by_email_cache_key, userprofile_by_user_cache_key, \
|
||||
user_by_id_cache_key
|
||||
user_by_id_cache_key, user_profile_by_id_cache_key
|
||||
|
||||
MESSAGE_CACHE_SIZE = 25000
|
||||
|
||||
@@ -36,6 +36,7 @@ def populate_user_cache():
|
||||
items_for_memcached[userprofile_by_email_cache_key(user_profile.user.email)] = (user_profile,)
|
||||
items_for_memcached[userprofile_by_user_cache_key(user_profile.user.id)] = (user_profile,)
|
||||
items_for_memcached[user_by_id_cache_key(user_profile.user.id)] = (user_profile.user,)
|
||||
items_for_memcached[user_profile_by_id_cache_key(user_profile.id)] = (user_profile,)
|
||||
|
||||
djcache.set_many(items_for_memcached, timeout=3600*24*7)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user