mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 00:23:49 +00:00
Have flush_realm() make O(1) cache_delete() calls in a couple places.
For the realm-wide caches of active user dicts and alert words, just make a single call to cache_delete() when you are deactivating a realm. Before this change, we were doing O(N) cache_deletes as part of the code path through flush_user_profile(). Now we just call update_user_profile_caches() directly to clear the user_profile caches. This change also sets us up to turn flush_realm() into a post-save hook. (imported from commit 699b4ea226ae15fc8c402cb4bc64ff6bdc041fc2)
This commit is contained in:
@@ -273,7 +273,11 @@ def flush_user_profile(sender, **kwargs):
|
||||
|
||||
def flush_realm(realm):
|
||||
for user in realm.get_active_users():
|
||||
flush_user_profile(None, instance=user, update_fields=None)
|
||||
update_user_profile_caches(user)
|
||||
|
||||
if realm.deactivated:
|
||||
cache_delete(active_user_dicts_in_realm_cache_key(realm))
|
||||
cache_delete(realm_alert_words_cache_key(realm))
|
||||
|
||||
def realm_alert_words_cache_key(realm):
|
||||
return "realm_alert_words:%s" % (realm.domain,)
|
||||
|
||||
Reference in New Issue
Block a user