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
0e42dfbe
Commit
0e42dfbe
authored
9 years ago
by
Mark Haines
Browse files
Options
Downloads
Plain Diff
Merge pull request #164 from matrix-org/markjh/pusher_performance_2
Add a cache for get_push rules for user, fix cache invalidation
parents
5ebd3330
a04cde61
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/push_rule.py
+17
-1
17 additions, 1 deletion
synapse/storage/push_rule.py
with
17 additions
and
1 deletion
synapse/storage/push_rule.py
+
17
−
1
View file @
0e42dfbe
...
...
@@ -23,6 +23,7 @@ logger = logging.getLogger(__name__)
class
PushRuleStore
(
SQLBaseStore
):
@cached
()
@defer.inlineCallbacks
def
get_push_rules_for_user
(
self
,
user_name
):
rows
=
yield
self
.
_simple_select_list
(
...
...
@@ -31,6 +32,7 @@ class PushRuleStore(SQLBaseStore):
"
user_name
"
:
user_name
,
},
retcols
=
PushRuleTable
.
fields
,
desc
=
"
get_push_rules_enabled_for_user
"
,
)
rows
.
sort
(
...
...
@@ -150,6 +152,10 @@ class PushRuleStore(SQLBaseStore):
txn
.
execute
(
sql
,
(
user_name
,
priority_class
,
new_rule_priority
))
txn
.
call_after
(
self
.
get_push_rules_for_user
.
invalidate
,
user_name
)
txn
.
call_after
(
self
.
get_push_rules_enabled_for_user
.
invalidate
,
user_name
)
...
...
@@ -182,6 +188,9 @@ class PushRuleStore(SQLBaseStore):
new_rule
[
'
priority_class
'
]
=
priority_class
new_rule
[
'
priority
'
]
=
new_prio
txn
.
call_after
(
self
.
get_push_rules_for_user
.
invalidate
,
user_name
)
txn
.
call_after
(
self
.
get_push_rules_enabled_for_user
.
invalidate
,
user_name
)
...
...
@@ -208,6 +217,8 @@ class PushRuleStore(SQLBaseStore):
{
'
user_name
'
:
user_name
,
'
rule_id
'
:
rule_id
},
desc
=
"
delete_push_rule
"
,
)
self
.
get_push_rules_for_user
.
invalidate
(
user_name
)
self
.
get_push_rules_enabled_for_user
.
invalidate
(
user_name
)
@defer.inlineCallbacks
...
...
@@ -228,7 +239,12 @@ class PushRuleStore(SQLBaseStore):
{
'
enabled
'
:
1
if
enabled
else
0
},
{
'
id
'
:
new_id
},
)
self
.
get_push_rules_enabled_for_user
.
invalidate
(
user_name
)
txn
.
call_after
(
self
.
get_push_rules_for_user
.
invalidate
,
user_name
)
txn
.
call_after
(
self
.
get_push_rules_enabled_for_user
.
invalidate
,
user_name
)
class
RuleNotFoundException
(
Exception
):
...
...
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