Run the memcached cache filling jobs in separate processes.

This will significantly improve the speed with which the memcached
caches are filled.

(imported from commit 445fec710a00b3d19b7962beddf89d4a75322eab)
This commit is contained in:
Tim Abbott
2013-03-26 12:24:02 -04:00
parent a774598a10
commit 36f09729e6
2 changed files with 22 additions and 12 deletions

View File

@@ -56,12 +56,13 @@ def populate_recipient_cache():
djcache.set_many(items_for_memcached, timeout=3600*24*7)
def fill_memcached_caches():
populate_user_cache()
logging.info("Succesfully populated user cache!")
populate_stream_cache()
logging.info("Succesfully populated stream cache!")
populate_recipient_cache()
logging.info("Succesfully populated recipient cache!")
populate_message_cache()
logging.info("Succesfully populated mesasge cache!")
cache_fillers = {
'user': populate_user_cache,
'recipient': populate_recipient_cache,
'stream': populate_stream_cache,
'message': populate_message_cache,
}
def fill_memcached_cache(cache):
cache_fillers[cache]()
logging.info("Succesfully populated %s cache!" % (cache,))