mirror of https://github.com/zulip/zulip.git
message_cache: Query related models to avoid more queries later.
(imported from commit c1442165c68e9eef1cb5d310624c1021c1a57350)
This commit is contained in:
parent
d88591c19c
commit
e78ef47487
|
@ -13,13 +13,12 @@ def cache_save_message(message):
|
|||
|
||||
@cache_with_key(message_cache_key)
|
||||
def cache_get_message(message_id):
|
||||
return Message.objects.select_related("sending_client", "sender").get(id=message_id)
|
||||
return Message.objects.select_related().get(id=message_id)
|
||||
|
||||
# Called on Tornado startup to ensure our message cache isn't empty
|
||||
def populate_message_cache():
|
||||
items_for_memcached = {}
|
||||
for m in Message.objects.select_related("sending_client", "sender").all().order_by(
|
||||
"-id")[0:MESSAGE_CACHE_SIZE]:
|
||||
for m in Message.objects.select_related().all().order_by("-id")[0:MESSAGE_CACHE_SIZE]:
|
||||
items_for_memcached[message_cache_key(m.id)] = (m,)
|
||||
|
||||
djcache.set_many(items_for_memcached, timeout=3600*24)
|
||||
|
|
Loading…
Reference in New Issue