def update_to_dict_cache(changed_messages: List[Message], realm_id: Optional[int]=None) -> List[int]:
    'Updates the message as stored in the to_dict cache (for serving\n    messages).'
    items_for_remote_cache = {}
    message_ids = []
    changed_messages_to_dict = MessageDict.to_dict_uncached(changed_messages, realm_id)
    for (msg_id, msg) in changed_messages_to_dict.items():
        message_ids.append(msg_id)
        key = to_dict_cache_key_id(msg_id)
        items_for_remote_cache[key] = (msg,)
    cache_set_many(items_for_remote_cache)
    return message_ids
Updates the message as stored in the to_dict cache (for serving
messages).
def update_to_dict_cache(changed_messages: List[Message], realm_id: Optional[int]=None) -> List[int]:
    'Updates the message as stored in the to_dict cache (for serving\n    messages).'
    items_for_remote_cache = {}
    message_ids = []
    changed_messages_to_dict = MessageDict.to_dict_uncached(changed_messages, realm_id)
    for (msg_id, msg) in changed_messages_to_dict.items():
        message_ids.append(msg_id)
        key = to_dict_cache_key_id(msg_id)
        items_for_remote_cache[key] = (msg,)
    cache_set_many(items_for_remote_cache)
    return message_ids