diff --git a/zephyr/lib/cache_helpers.py b/zephyr/lib/cache_helpers.py index 115b9f568c..d4ca8611cf 100644 --- a/zephyr/lib/cache_helpers.py +++ b/zephyr/lib/cache_helpers.py @@ -2,7 +2,8 @@ # cannot import anything from zephyr.models or we'd have an import # loop from zephyr.models import Message, UserProfile, Stream, get_stream_cache_key, \ - Recipient, get_recipient_cache_key, Client, get_client_cache_key + Recipient, get_recipient_cache_key, Client, get_client_cache_key, \ + Huddle, huddle_hash_cache_key from zephyr.lib.cache import cache_with_key, djcache, message_cache_key, \ user_profile_by_email_cache_key, user_profile_by_user_cache_key, \ user_by_id_cache_key, user_profile_by_id_cache_key @@ -56,6 +57,13 @@ def populate_client_cache(): djcache.set_many(items_for_memcached, timeout=3600*24*7) +def populate_huddle_cache(): + items_for_memcached = {} + for huddle in Huddle.objects.select_related().all(): + items_for_memcached[huddle_hash_cache_key(huddle.huddle_hash)] = (huddle,) + + djcache.set_many(items_for_memcached, timeout=3600*24*7) + def populate_recipient_cache(): items_for_memcached = {} for recipient in Recipient.objects.select_related().all(): @@ -69,6 +77,7 @@ cache_fillers = { 'recipient': populate_recipient_cache, 'stream': populate_stream_cache, 'message': populate_message_cache, + 'huddle': populate_huddle_cache, } def fill_memcached_cache(cache):