diff options
author | Mark Haines <mjark@negativecurvature.net> | 2015-12-10 18:01:46 +0000 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2015-12-10 18:01:46 +0000 |
commit | e0c9f30efae8dc7d07df1d12b8e74a755e0600ca (patch) | |
tree | 0d3846edca33b49c1e4776a95733edeefebff720 /synapse/storage/roommember.py | |
parent | Mark the version as a -rc1 release candidate (diff) | |
parent | Missing yield (diff) | |
download | synapse-e0c9f30efae8dc7d07df1d12b8e74a755e0600ca.tar.xz |
Merge pull request #434 from matrix-org/markjh/forget_rooms
Add caches for whether a room has been forgotten by a user
Diffstat (limited to 'synapse/storage/roommember.py')
-rw-r--r-- | synapse/storage/roommember.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py index 69398b7c8e..e1777d7afa 100644 --- a/synapse/storage/roommember.py +++ b/synapse/storage/roommember.py @@ -18,7 +18,7 @@ from twisted.internet import defer from collections import namedtuple from ._base import SQLBaseStore -from synapse.util.caches.descriptors import cached +from synapse.util.caches.descriptors import cached, cachedInlineCallbacks from synapse.api.constants import Membership from synapse.types import UserID @@ -270,6 +270,7 @@ class RoomMemberStore(SQLBaseStore): defer.returnValue(ret) + @defer.inlineCallbacks def forget(self, user_id, room_id): """Indicate that user_id wishes to discard history for room_id.""" def f(txn): @@ -284,9 +285,11 @@ class RoomMemberStore(SQLBaseStore): " room_id = ?" ) txn.execute(sql, (user_id, room_id)) - self.runInteraction("forget_membership", f) + yield self.runInteraction("forget_membership", f) + self.was_forgotten_at.invalidate_all() + self.did_forget.invalidate((user_id, room_id)) - @defer.inlineCallbacks + @cachedInlineCallbacks(num_args=2) def did_forget(self, user_id, room_id): """Returns whether user_id has elected to discard history for room_id. @@ -310,7 +313,7 @@ class RoomMemberStore(SQLBaseStore): count = yield self.runInteraction("did_forget_membership", f) defer.returnValue(count == 0) - @defer.inlineCallbacks + @cachedInlineCallbacks(num_args=3) def was_forgotten_at(self, user_id, room_id, event_id): """Returns whether user_id has elected to discard history for room_id at event_id. |