summary refs log tree commit diff
path: root/synapse/storage/presence.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-03-27 15:57:16 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-03-27 15:57:16 +0000
commitff1fa0fbf80cbb636e4cce59846bb5dcc91ccd03 (patch)
tree50677ebb8eeefae3ae37ecd4271146bdaa68071a /synapse/storage/presence.py
parentMerge pull request #115 from matrix-org/allow_registration_for_federation_demo (diff)
downloadsynapse-ff1fa0fbf80cbb636e4cce59846bb5dcc91ccd03.tar.xz
Add another @cached wrapper, this time on get_presence_state()
Diffstat (limited to '')
-rw-r--r--synapse/storage/presence.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/synapse/storage/presence.py b/synapse/storage/presence.py
index 87fba55439..e6fc19ccec 100644
--- a/synapse/storage/presence.py
+++ b/synapse/storage/presence.py
@@ -13,7 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from ._base import SQLBaseStore
+from twisted.internet import defer
+
+from ._base import SQLBaseStore, cached
 
 
 class PresenceStore(SQLBaseStore):
@@ -33,6 +35,7 @@ class PresenceStore(SQLBaseStore):
             desc="has_presence_state",
         )
 
+    @cached()
     def get_presence_state(self, user_localpart):
         return self._simple_select_one(
             table="presence",
@@ -41,8 +44,9 @@ class PresenceStore(SQLBaseStore):
             desc="get_presence_state",
         )
 
+    @defer.inlineCallbacks
     def set_presence_state(self, user_localpart, new_state):
-        return self._simple_update_one(
+        ret = yield self._simple_update_one(
             table="presence",
             keyvalues={"user_id": user_localpart},
             updatevalues={"state": new_state["state"],
@@ -50,6 +54,8 @@ class PresenceStore(SQLBaseStore):
                           "mtime": self._clock.time_msec()},
             desc="set_presence_state",
         )
+        self.get_presence_state.invalidate(user_localpart)
+        defer.returnValue(ret)
 
     def allow_presence_visible(self, observed_localpart, observer_userid):
         return self._simple_insert(