mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 03:41:58 +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:
@@ -15,6 +15,7 @@ from django.utils import timezone
|
||||
from zephyr.lib.create_user import create_user
|
||||
from zephyr.lib.bulk_create import batch_bulk_create
|
||||
from zephyr.lib import bugdown
|
||||
from zephyr.lib.cache import cache_with_key, user_profile_by_id_cache_key
|
||||
|
||||
import subprocess
|
||||
import simplejson
|
||||
@@ -122,10 +123,8 @@ def log_message(message):
|
||||
if not message.sending_client.name.startswith("test:"):
|
||||
log_event(message.to_log_dict())
|
||||
|
||||
user_hash = {}
|
||||
@cache_with_key(user_profile_by_id_cache_key)
|
||||
def get_user_profile_by_id(uid):
|
||||
if uid in user_hash:
|
||||
return user_hash[uid]
|
||||
return UserProfile.objects.select_related().get(id=uid)
|
||||
|
||||
def do_send_message(message, rendered_content=None, no_log=False,
|
||||
|
||||
Reference in New Issue
Block a user