mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 12:04:53 -04:00
Reduce size of joined_user cache
The _get_joined_users_from_context cache stores a mapping from user_id to avatar_url and display_name. Instead of storing those in a dict, store them in a namedtuple as that uses much less memory. We also try converting the string to ascii to further reduce the size.
This commit is contained in:
parent
22f3d3ae76
commit
d9aa645f86
4 changed files with 40 additions and 11 deletions
|
@ -40,3 +40,17 @@ def is_ascii(s):
|
|||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def to_ascii(s):
|
||||
"""Converts a string to ascii if it is ascii, otherwise leave it alone.
|
||||
|
||||
If given None then will return None.
|
||||
"""
|
||||
if s is None:
|
||||
return None
|
||||
|
||||
try:
|
||||
return s.encode("ascii")
|
||||
except UnicodeEncodeError:
|
||||
return s
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue