tornado: Cache messages internally in tornado process.

This allows us to handle the return_messages_immediately part of
get_updates requests without having to talk to the database.

(imported from commit ed0b7742d359efb21a0a4960f4fc25f4337e9ad4)
This commit is contained in:
Tim Abbott
2013-01-09 14:35:19 -05:00
parent 7e62ef5a03
commit a058471a56
4 changed files with 90 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ from zephyr.models import Realm, Stream, UserProfile, \
from django.db import transaction, IntegrityError
from zephyr.lib.initial_password import initial_password
from zephyr.lib.cache import cache_with_key
from zephyr.lib.message_cache import cache_save_message
from django.utils import timezone
from django.contrib.auth.models import UserManager
@@ -145,6 +146,8 @@ def do_send_message(message, no_log=False):
if user_profile.user.is_active:
UserMessage(user_profile=user_profile, message=message).save()
cache_save_message(message)
# We can only publish messages to longpolling clients if the Tornado server is running.
if settings.TORNADO_SERVER:
# Render Markdown etc. here, so that the single-threaded Tornado server doesn't have to.