diff options
author | David Baker <dbkr@users.noreply.github.com> | 2016-01-22 14:47:48 +0000 |
---|---|---|
committer | David Baker <dbkr@users.noreply.github.com> | 2016-01-22 14:47:48 +0000 |
commit | 7a3fe48ba48d99f02b4bfd556199571f95fc8e1c (patch) | |
tree | 740e160954c47d5362c22661bb141c31cdfbf118 /synapse/storage | |
parent | Merge pull request #517 from matrix-org/erikj/push_only_room (diff) | |
parent | Don't add the member functiopn if we're not using treecache (diff) | |
download | synapse-7a3fe48ba48d99f02b4bfd556199571f95fc8e1c.tar.xz |
Merge pull request #519 from matrix-org/dbkr/treecache
Make LRU caching tree-based so subtrees of the cache can be invalidated cheaply.
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/event_push_actions.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/synapse/storage/event_push_actions.py b/synapse/storage/event_push_actions.py index aa61cf5569..a05c4f84cf 100644 --- a/synapse/storage/event_push_actions.py +++ b/synapse/storage/event_push_actions.py @@ -40,14 +40,20 @@ class EventPushActionsStore(SQLBaseStore): 'actions': json.dumps(actions) }) + def f(txn): + for uid, _, __ in tuples: + txn.call_after( + self.get_unread_event_push_actions_by_room_for_user.invalidate_many, + (event.room_id, uid) + ) + return self._simple_insert_many_txn(txn, "event_push_actions", values) + yield self.runInteraction( "set_actions_for_event_and_users", - self._simple_insert_many_txn, - "event_push_actions", - values + f, ) - @cachedInlineCallbacks(num_args=3) + @cachedInlineCallbacks(num_args=3, lru=True, tree=True) def get_unread_event_push_actions_by_room_for_user( self, room_id, user_id, last_read_event_id ): @@ -98,6 +104,11 @@ class EventPushActionsStore(SQLBaseStore): @defer.inlineCallbacks def remove_push_actions_for_event_id(self, room_id, event_id): def f(txn): + # Sad that we have to blow away the cache for the whole room here + txn.call_after( + self.get_unread_event_push_actions_by_room_for_user.invalidate_many, + (room_id,) + ) txn.execute( "DELETE FROM event_push_actions WHERE room_id = ? AND event_id = ?", (room_id, event_id) |