From adb9c8815180e537a3bf7f9cfc684eaa5288af03 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 13 Mar 2013 14:07:29 -0400 Subject: [PATCH] message_cache: Clean up populate_message_cache. (imported from commit a73e4fc4908d840f4f02aef13a9afe2fb683fd83) --- zephyr/lib/message_cache.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/zephyr/lib/message_cache.py b/zephyr/lib/message_cache.py index 0410d1fe01..1f6fc233f7 100644 --- a/zephyr/lib/message_cache.py +++ b/zephyr/lib/message_cache.py @@ -12,14 +12,9 @@ def cache_get_message(message_id): # Called on Tornado startup to ensure our message cache isn't empty def populate_message_cache(): - max_message_id = 0 - min_message_id = 0 - messages_for_memcached = {} + items_for_memcached = {} for m in Message.objects.select_related("sender", "client").all().order_by( "-id")[0:MESSAGE_CACHE_SIZE]: - max_message_id = max(m.id, max_message_id) - min_message_id = min(m.id, min_message_id) - messages_for_memcached[message_cache_key(m.id)] = (m,) + items_for_memcached[message_cache_key(m.id)] = (m,) - djcache.set_many(messages_for_memcached, timeout=3600*24) - return max_message_id, min_message_id + djcache.set_many(items_for_memcached, timeout=3600*24)