mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
Flush cache on all user presence updates.
(imported from commit 130eac36f9932350a29ed88f11dd3e2f6bf3f979)
This commit is contained in:
@@ -257,11 +257,14 @@ def status_dict_cache_key(user_profile):
|
||||
return status_dict_cache_key_for_realm_id(user_profile.realm_id)
|
||||
|
||||
def update_user_presence_cache(sender, **kwargs):
|
||||
# For any status update, flush the user's realm's entry in the
|
||||
# UserPresence cache to avoid giving out stale state. Since we
|
||||
# get a lot of presence updates, we are likely to get cache misses
|
||||
# when new messages come in, but the query is pretty quick, and we
|
||||
# no longer have the issue of Tornado needing to go the cache or DB
|
||||
# to get presence info.
|
||||
user_profile = kwargs['instance'].user_profile
|
||||
if kwargs['update_fields'] is None or "status" in kwargs['update_fields']:
|
||||
# If the status of the user changed, flush the user's realm's
|
||||
# entry in the UserPresence cache to avoid giving out stale state
|
||||
djcache.delete(KEY_PREFIX + status_dict_cache_key(user_profile))
|
||||
djcache.delete(KEY_PREFIX + status_dict_cache_key(user_profile))
|
||||
|
||||
def realm_alert_words_cache_key(realm):
|
||||
return "realm_alert_words:%s" % (realm.domain,)
|
||||
|
||||
Reference in New Issue
Block a user