mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
Add memcached caching for get_stream lookups.
(imported from commit a089c8a99eaa1fa28ce401859cac1bdf0eb92a69)
This commit is contained in:
@@ -172,7 +172,15 @@ def get_client(name):
|
|||||||
return Client.objects.get(name=name)
|
return Client.objects.get(name=name)
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
def get_stream_cache_key(stream_name, realm):
|
||||||
|
if isinstance(realm, Realm):
|
||||||
|
realm_id = realm.id
|
||||||
|
else:
|
||||||
|
realm_id = realm
|
||||||
|
return "stream_by_realm_and_name:%s:%s" % (realm_id, hashlib.sha1(stream_name.strip().lower()).hexdigest())
|
||||||
|
|
||||||
# get_stream takes either a realm id or a realm
|
# get_stream takes either a realm id or a realm
|
||||||
|
@cache_with_key(get_stream_cache_key)
|
||||||
def get_stream(stream_name, realm):
|
def get_stream(stream_name, realm):
|
||||||
if isinstance(realm, Realm):
|
if isinstance(realm, Realm):
|
||||||
realm_id = realm.id
|
realm_id = realm.id
|
||||||
|
|||||||
Reference in New Issue
Block a user