mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-19 04:39:15 -04:00
Cache tags and account data
This commit is contained in:
parent
c23a8c7833
commit
00cb3eb24b
7 changed files with 137 additions and 102 deletions
|
@ -15,6 +15,7 @@
|
|||
|
||||
from ._base import SQLBaseStore
|
||||
from synapse.util.caches.descriptors import cached
|
||||
from synapse.util.caches.stream_change_cache import StreamChangeCache
|
||||
from twisted.internet import defer
|
||||
|
||||
import ujson as json
|
||||
|
@ -24,6 +25,13 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class TagsStore(SQLBaseStore):
|
||||
def __init__(self, hs):
|
||||
super(TagsStore, self).__init__(hs)
|
||||
|
||||
self._tags_stream_cache = StreamChangeCache(
|
||||
"TagsChangeCache", self._account_data_id_gen.get_max_token(None),
|
||||
max_size=1000,
|
||||
)
|
||||
|
||||
def get_max_account_data_stream_id(self):
|
||||
"""Get the current max stream id for the private user data stream
|
||||
|
@ -80,6 +88,10 @@ class TagsStore(SQLBaseStore):
|
|||
room_ids = [row[0] for row in txn.fetchall()]
|
||||
return room_ids
|
||||
|
||||
changed = self._tags_stream_cache.get_entity_has_changed(user_id, int(stream_id))
|
||||
if not changed:
|
||||
defer.returnValue({})
|
||||
|
||||
room_ids = yield self.runInteraction(
|
||||
"get_updated_tags", get_updated_tags_txn
|
||||
)
|
||||
|
@ -177,6 +189,8 @@ class TagsStore(SQLBaseStore):
|
|||
next_id(int): The the revision to advance to.
|
||||
"""
|
||||
|
||||
txn.call_after(self._tags_stream_cache.entity_has_changed, user_id, next_id)
|
||||
|
||||
update_max_id_sql = (
|
||||
"UPDATE account_data_max_stream_id"
|
||||
" SET stream_id = ?"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue