Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add cache to get_user_by_id #772

Merged
merged 1 commit into from
May 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions synapse/storage/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def register(self, user_id, token, password_hash,
make_guest,
appservice_id
)
self.get_user_by_id.invalidate((user_id,))
self.is_guest.invalidate((user_id,))

def _register(
Expand Down Expand Up @@ -156,6 +157,7 @@ def _register(
(next_id, user_id, token,)
)

@cached()
def get_user_by_id(self, user_id):
return self._simple_select_one(
table="users",
Expand Down Expand Up @@ -193,6 +195,7 @@ def user_set_password_hash(self, user_id, password_hash):
}, {
'password_hash': password_hash
})
self.get_user_by_id.invalidate((user_id,))

@defer.inlineCallbacks
def user_delete_access_tokens(self, user_id, except_token_ids=[]):
Expand Down