summary refs log tree commit diff
path: root/synapse/storage/registration.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2015-03-17 17:24:51 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2015-03-17 17:24:51 +0000
commit93978c5e2beb22b097061e58182777e9c2257228 (patch)
tree7abf35f400a4f83f3534f22213641fc6c228b963 /synapse/storage/registration.py
parentBe polite and ensure we use @functools.wraps() when creating a function decor... (diff)
downloadsynapse-93978c5e2beb22b097061e58182777e9c2257228.tar.xz
@cached() annotate get_user_by_token() - achieves a minor DB performance improvement
Diffstat (limited to 'synapse/storage/registration.py')
-rw-r--r--synapse/storage/registration.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index adc8fc0794..3c2f1d6a15 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -19,7 +19,7 @@ from sqlite3 import IntegrityError
 
 from synapse.api.errors import StoreError, Codes
 
-from ._base import SQLBaseStore
+from ._base import SQLBaseStore, cached
 
 
 class RegistrationStore(SQLBaseStore):
@@ -91,6 +91,11 @@ class RegistrationStore(SQLBaseStore):
             "get_user_by_id", self.cursor_to_dict, query, user_id
         )
 
+    @cached()
+    # TODO(paul): Currently there's no code to invalidate this cache. That
+    #   means if/when we ever add internal ways to invalidate access tokens or
+    #   change whether a user is a server admin, those will need to invoke
+    #      store.get_user_by_token.invalidate(token)
     def get_user_by_token(self, token):
         """Get a user from the given access token.