Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
8571f864
Commit
8571f864
authored
7 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Cache one time key counts
parent
dcabef95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/end_to_end_keys.py
+9
-0
9 additions, 0 deletions
synapse/storage/end_to_end_keys.py
with
9 additions
and
0 deletions
synapse/storage/end_to_end_keys.py
+
9
−
0
View file @
8571f864
...
...
@@ -15,6 +15,7 @@
from
twisted.internet
import
defer
from
synapse.api.errors
import
SynapseError
from
synapse.util.caches.descriptors
import
cached
from
canonicaljson
import
encode_canonical_json
import
ujson
as
json
...
...
@@ -177,10 +178,14 @@ class EndToEndKeyStore(SQLBaseStore):
for
algorithm
,
key_id
,
json_bytes
in
new_keys
],
)
txn
.
call_after
(
self
.
count_e2e_one_time_keys
.
invalidate
,
(
user_id
,
device_id
,)
)
yield
self
.
runInteraction
(
"
add_e2e_one_time_keys_insert
"
,
_add_e2e_one_time_keys
)
@cached
(
max_entries
=
10000
)
def
count_e2e_one_time_keys
(
self
,
user_id
,
device_id
):
"""
Count the number of one time keys the server has for a device
Returns:
...
...
@@ -225,6 +230,9 @@ class EndToEndKeyStore(SQLBaseStore):
)
for
user_id
,
device_id
,
algorithm
,
key_id
in
delete
:
txn
.
execute
(
sql
,
(
user_id
,
device_id
,
algorithm
,
key_id
))
txn
.
call_after
(
self
.
count_e2e_one_time_keys
.
invalidate
,
(
user_id
,
device_id
,)
)
return
result
return
self
.
runInteraction
(
"
claim_e2e_one_time_keys
"
,
_claim_e2e_one_time_keys
...
...
@@ -242,3 +250,4 @@ class EndToEndKeyStore(SQLBaseStore):
keyvalues
=
{
"
user_id
"
:
user_id
,
"
device_id
"
:
device_id
},
desc
=
"
delete_e2e_one_time_keys_by_device
"
)
self
.
count_e2e_one_time_keys
.
invalidate
((
user_id
,
device_id
,))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment