Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

streams: Skip pickling the recipient string in cache.

Alex Vandiver9c92fe8f3480
diff --git a/zerver/actions/streams.py b/zerver/actions/streams.py
index 2e39de4ba71..781d32db5ea 100644
--- a/zerver/actions/streams.py
+++ b/zerver/actions/streams.py
@@ -261,7 +261,7 @@ def do_unarchive_stream(stream: Stream, new_name: str, *, acting_user: UserProfi
ChannelEmailAddress.objects.filter(realm=realm, channel=stream).update(deactivated=False)
# Update caches
- cache_set(display_recipient_cache_key(stream.recipient_id), new_name)
+ cache_set(display_recipient_cache_key(stream.recipient_id), new_name, pickled_tupled=False)
messages = Message.objects.filter(
# Uses index: zerver_message_realm_recipient_id
realm_id=realm.id,
@@ -1516,7 +1516,7 @@ def do_rename_stream(stream: Stream, new_name: str, user_profile: UserProfile) -
recipient_id=recipient_id,
).only("id")
- cache_set(display_recipient_cache_key(recipient_id), stream.name)
+ cache_set(display_recipient_cache_key(recipient_id), stream.name, pickled_tupled=False)
# Delete cache entries for everything else, which is cheaper and
# clearer than trying to set them. display_recipient is the out of
diff --git a/zerver/lib/display_recipient.py b/zerver/lib/display_recipient.py
index 99009d6b355..976af4c5e8a 100644
--- a/zerver/lib/display_recipient.py
+++ b/zerver/lib/display_recipient.py
@@ -34,6 +34,9 @@ def get_display_recipient_cache_key(
return display_recipient_cache_key(recipient_id)
+# Note that the _same_ cache key is used for streams, which contain a
+# string, not a list[UserDisplayRecipient]! This works because the
+# recipient space is distinct between the two.
@cache_with_key(get_display_recipient_cache_key, timeout=3600 * 24 * 7)
def get_display_recipient_remote_cache(
recipient_id: int, recipient_type: int, recipient_type_id: int | None
@@ -121,6 +124,7 @@ def bulk_fetch_stream_names(
cache_transformer=get_name,
setter=lambda obj: obj,
extractor=lambda obj: obj,
+ pickled_tupled=False,
)
return stream_display_recipients