Remove now-unused message_cache_key message cache.

Originally this cache was used to transmit data from Django to Tornado
(and also for general message caching purposes), but now nothing
actually reads from this cache, so we can eliminate it.
This commit is contained in:
Tim Abbott
2016-07-07 17:24:59 -07:00
committed by Rishi Gupta
parent 8d5ec14b31
commit 72e948d19a
4 changed files with 3 additions and 20 deletions

View File

@@ -46,14 +46,13 @@ session_engine = import_module(settings.SESSION_ENGINE)
from zerver.lib.create_user import random_api_key from zerver.lib.create_user import random_api_key
from zerver.lib.timestamp import timestamp_to_datetime, datetime_to_timestamp from zerver.lib.timestamp import timestamp_to_datetime, datetime_to_timestamp
from zerver.lib.cache_helpers import cache_save_message
from zerver.lib.queue import queue_json_publish from zerver.lib.queue import queue_json_publish
from django.utils import timezone from django.utils import timezone
from zerver.lib.create_user import create_user from zerver.lib.create_user import create_user
from zerver.lib import bugdown from zerver.lib import bugdown
from zerver.lib.cache import cache_with_key, cache_set, \ from zerver.lib.cache import cache_with_key, cache_set, \
user_profile_by_email_cache_key, cache_set_many, \ user_profile_by_email_cache_key, cache_set_many, \
cache_delete, cache_delete_many, message_cache_key cache_delete, cache_delete_many
from zerver.decorator import statsd_increment from zerver.decorator import statsd_increment
from zerver.lib.event_queue import request_event_queue, get_user_events, send_event from zerver.lib.event_queue import request_event_queue, get_user_events, send_event
from zerver.lib.utils import log_statsd_event, statsd from zerver.lib.utils import log_statsd_event, statsd
@@ -683,7 +682,6 @@ def do_send_messages(messages):
do_claim_attachments(message) do_claim_attachments(message)
for message in messages: for message in messages:
cache_save_message(message['message'])
# Render Markdown etc. here and store (automatically) in # Render Markdown etc. here and store (automatically) in
# remote cache, so that the single-threaded Tornado server # remote cache, so that the single-threaded Tornado server
# doesn't have to. # doesn't have to.
@@ -1796,7 +1794,6 @@ def do_rename_stream(realm, old_name, new_name, log=True):
# Delete cache entries for everything else, which is cheaper and # Delete cache entries for everything else, which is cheaper and
# clearer than trying to set them. display_recipient is the out of # clearer than trying to set them. display_recipient is the out of
# date field in all cases. # date field in all cases.
cache_delete_many(message_cache_key(message.id) for message in messages)
cache_delete_many( cache_delete_many(
to_dict_cache_key_id(message.id, True) for message in messages) to_dict_cache_key_id(message.id, True) for message in messages)
cache_delete_many( cache_delete_many(
@@ -2490,7 +2487,6 @@ def do_update_message(user_profile, message_id, subject, propagate_mode, content
event['message_ids'] = [] event['message_ids'] = []
for changed_message in changed_messages: for changed_message in changed_messages:
event['message_ids'].append(changed_message.id) event['message_ids'].append(changed_message.id)
items_for_remote_cache[message_cache_key(changed_message.id)] = (changed_message,)
items_for_remote_cache[to_dict_cache_key(changed_message, True)] = \ items_for_remote_cache[to_dict_cache_key(changed_message, True)] = \
(stringify_message_dict(changed_message.to_dict_uncached(apply_markdown=True)),) (stringify_message_dict(changed_message.to_dict_uncached(apply_markdown=True)),)
items_for_remote_cache[to_dict_cache_key(changed_message, False)] = \ items_for_remote_cache[to_dict_cache_key(changed_message, False)] = \

View File

@@ -252,10 +252,6 @@ def cache(func):
return cache_with_key(keyfunc)(func) return cache_with_key(keyfunc)(func)
def message_cache_key(message_id):
# type: (int) -> text_type
return u"message:%d" % (message_id,)
def display_recipient_cache_key(recipient_id): def display_recipient_cache_key(recipient_id):
# type: (int) -> text_type # type: (int) -> text_type
return u"display_recipient_dict:%d" % (recipient_id,) return u"display_recipient_dict:%d" % (recipient_id,)

View File

@@ -10,7 +10,7 @@ from django.conf import settings
from zerver.models import Message, UserProfile, Stream, get_stream_cache_key, \ from zerver.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, to_dict_cache_key_id, stringify_message_dict Huddle, huddle_hash_cache_key, to_dict_cache_key_id, stringify_message_dict
from zerver.lib.cache import cache_with_key, cache_set, message_cache_key, \ from zerver.lib.cache import cache_with_key, cache_set, \
user_profile_by_email_cache_key, user_profile_by_id_cache_key, \ user_profile_by_email_cache_key, user_profile_by_id_cache_key, \
get_remote_cache_time, get_remote_cache_requests, cache_set_many get_remote_cache_time, get_remote_cache_requests, cache_set_many
from django.utils.importlib import import_module from django.utils.importlib import import_module
@@ -20,15 +20,6 @@ from django.db.models import Q
MESSAGE_CACHE_SIZE = 75000 MESSAGE_CACHE_SIZE = 75000
def cache_save_message(message):
# type: (Message) -> None
cache_set(message_cache_key(message.id), message, timeout=3600*24)
@cache_with_key(message_cache_key, timeout=3600*24)
def cache_get_message(message_id):
# type: (int) -> Message
return Message.objects.select_related().get(id=message_id)
def message_fetch_objects(): def message_fetch_objects():
# type: () -> List[Any] # type: () -> List[Any]
try: try:

View File

@@ -21,7 +21,7 @@ import random
import traceback import traceback
from zerver.models import UserProfile, Client from zerver.models import UserProfile, Client
from zerver.decorator import RespondAsynchronously from zerver.decorator import RespondAsynchronously
from zerver.lib.cache import cache_get_many, message_cache_key, \ from zerver.lib.cache import cache_get_many, \
user_profile_by_id_cache_key, cache_save_user_profile, cache_with_key user_profile_by_id_cache_key, cache_save_user_profile, cache_with_key
from zerver.lib.handlers import clear_handler_by_id, get_handler_by_id, \ from zerver.lib.handlers import clear_handler_by_id, get_handler_by_id, \
finish_handler, handler_stats_string finish_handler, handler_stats_string