diff options
author | Erik Johnston <erik@matrix.org> | 2019-05-16 09:56:12 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-05-16 10:02:14 +0100 |
commit | 33453419b0cbbe29d3f4b376e9eafab10d5d012a (patch) | |
tree | 2f98e18112d975eb91041361877f07e39ad0dc48 /synapse/storage/relations.py | |
parent | Add aggregations API (diff) | |
download | synapse-33453419b0cbbe29d3f4b376e9eafab10d5d012a.tar.xz |
Add cache to relations
Diffstat (limited to 'synapse/storage/relations.py')
-rw-r--r-- | synapse/storage/relations.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/synapse/storage/relations.py b/synapse/storage/relations.py index db4b842c97..1fd3d4fafc 100644 --- a/synapse/storage/relations.py +++ b/synapse/storage/relations.py @@ -21,6 +21,7 @@ from synapse.api.constants import RelationTypes from synapse.api.errors import SynapseError from synapse.storage._base import SQLBaseStore from synapse.storage.stream import generate_pagination_where_clause +from synapse.util.caches.descriptors import cached logger = logging.getLogger(__name__) @@ -109,6 +110,7 @@ class AggregationPaginationToken(object): class RelationsStore(SQLBaseStore): + @cached(tree=True) def get_relations_for_event( self, event_id, @@ -216,6 +218,7 @@ class RelationsStore(SQLBaseStore): "get_recent_references_for_event", _get_recent_references_for_event_txn ) + @cached(tree=True) def get_aggregation_groups_for_event( self, event_id, @@ -353,3 +356,8 @@ class RelationsStore(SQLBaseStore): "aggregation_key": aggregation_key, }, ) + + txn.call_after(self.get_relations_for_event.invalidate_many, (parent_id,)) + txn.call_after( + self.get_aggregation_groups_for_event.invalidate_many, (parent_id,) + ) |