mirror of https://github.com/zulip/zulip.git
tornado: Don't attempt to populate the memcached on restart.
Later, we can fork off a separate process to do that task, but for now, we can just rely on the fact that unless the server was just rebooted, the relevant messages will already be in that cache, and even if it was, getting the needed messages once each is not a particularly expensive query. (imported from commit 6d08eba1b41237fd4e1204e181ce8f227573930d)
This commit is contained in:
parent
d121c51584
commit
bea03548c2
|
@ -62,13 +62,16 @@ def add_pointer_update_callback(user_profile, cb):
|
|||
# * O(k) read of highest k message ids
|
||||
# * Automatic maximum size support.
|
||||
user_messages = {}
|
||||
CACHE_COUNT = 25000
|
||||
USERMESSAGE_CACHE_COUNT = 25000
|
||||
cache_minimum_id = sys.maxint
|
||||
def initialize_user_messages():
|
||||
global cache_minimum_id
|
||||
max_message_id, cache_minimum_id = populate_message_cache(CACHE_COUNT)
|
||||
try:
|
||||
cache_minimum_id = Message.objects.all().order_by("-id")[0].id - USERMESSAGE_CACHE_COUNT
|
||||
except Message.DoesNotExist:
|
||||
cache_minimum_id = 1
|
||||
|
||||
for um in UserMessage.objects.filter(message_id__gt=max_message_id - CACHE_COUNT).order_by("message"):
|
||||
for um in UserMessage.objects.filter(message_id__gte=cache_minimum_id).order_by("message"):
|
||||
add_user_message(um.user_profile_id, um.message_id)
|
||||
|
||||
def add_user_message(user_profile_id, message_id):
|
||||
|
|
Loading…
Reference in New Issue