Amalgamate tags and account data stream caches
parent
3f5dd18bd4
commit
467c27a1f9
|
@ -28,7 +28,8 @@ class AccountDataStore(SQLBaseStore):
|
||||||
super(AccountDataStore, self).__init__(hs)
|
super(AccountDataStore, self).__init__(hs)
|
||||||
|
|
||||||
self._account_data_stream_cache = StreamChangeCache(
|
self._account_data_stream_cache = StreamChangeCache(
|
||||||
"AccountDataChangeCache", self._account_data_id_gen.get_max_token(None),
|
"AccountDataAndTagsChangeCache",
|
||||||
|
self._account_data_id_gen.get_max_token(None),
|
||||||
max_size=1000,
|
max_size=1000,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
from ._base import SQLBaseStore
|
from ._base import SQLBaseStore
|
||||||
from synapse.util.caches.descriptors import cached
|
from synapse.util.caches.descriptors import cached
|
||||||
from synapse.util.caches.stream_change_cache import StreamChangeCache
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
import ujson as json
|
import ujson as json
|
||||||
|
@ -25,14 +24,6 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class TagsStore(SQLBaseStore):
|
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):
|
def get_max_account_data_stream_id(self):
|
||||||
"""Get the current max stream id for the private user data stream
|
"""Get the current max stream id for the private user data stream
|
||||||
|
|
||||||
|
@ -88,7 +79,9 @@ class TagsStore(SQLBaseStore):
|
||||||
room_ids = [row[0] for row in txn.fetchall()]
|
room_ids = [row[0] for row in txn.fetchall()]
|
||||||
return room_ids
|
return room_ids
|
||||||
|
|
||||||
changed = self._tags_stream_cache.has_entity_changed(user_id, int(stream_id))
|
changed = self._account_data_stream_cache.has_entity_changed(
|
||||||
|
user_id, int(stream_id)
|
||||||
|
)
|
||||||
if not changed:
|
if not changed:
|
||||||
defer.returnValue({})
|
defer.returnValue({})
|
||||||
|
|
||||||
|
@ -189,7 +182,10 @@ class TagsStore(SQLBaseStore):
|
||||||
next_id(int): The the revision to advance to.
|
next_id(int): The the revision to advance to.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
txn.call_after(self._tags_stream_cache.entity_has_changed, user_id, next_id)
|
txn.call_after(
|
||||||
|
self._account_data_stream_cache.entity_has_changed,
|
||||||
|
user_id, next_id
|
||||||
|
)
|
||||||
|
|
||||||
update_max_id_sql = (
|
update_max_id_sql = (
|
||||||
"UPDATE account_data_max_stream_id"
|
"UPDATE account_data_max_stream_id"
|
||||||
|
|
Loading…
Reference in New Issue