mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-11 11:34:23 -05:00
Add a cache for get_push rules for user, fix cache invalidation
This commit is contained in:
parent
4429e720ae
commit
a04cde613e
@ -23,6 +23,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class PushRuleStore(SQLBaseStore):
|
class PushRuleStore(SQLBaseStore):
|
||||||
|
@cached()
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_push_rules_for_user(self, user_name):
|
def get_push_rules_for_user(self, user_name):
|
||||||
rows = yield self._simple_select_list(
|
rows = yield self._simple_select_list(
|
||||||
@ -31,6 +32,7 @@ class PushRuleStore(SQLBaseStore):
|
|||||||
"user_name": user_name,
|
"user_name": user_name,
|
||||||
},
|
},
|
||||||
retcols=PushRuleTable.fields,
|
retcols=PushRuleTable.fields,
|
||||||
|
desc="get_push_rules_enabled_for_user",
|
||||||
)
|
)
|
||||||
|
|
||||||
rows.sort(
|
rows.sort(
|
||||||
@ -150,6 +152,10 @@ class PushRuleStore(SQLBaseStore):
|
|||||||
|
|
||||||
txn.execute(sql, (user_name, priority_class, new_rule_priority))
|
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(
|
txn.call_after(
|
||||||
self.get_push_rules_enabled_for_user.invalidate, user_name
|
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_class'] = priority_class
|
||||||
new_rule['priority'] = new_prio
|
new_rule['priority'] = new_prio
|
||||||
|
|
||||||
|
txn.call_after(
|
||||||
|
self.get_push_rules_for_user.invalidate, user_name
|
||||||
|
)
|
||||||
txn.call_after(
|
txn.call_after(
|
||||||
self.get_push_rules_enabled_for_user.invalidate, user_name
|
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},
|
{'user_name': user_name, 'rule_id': rule_id},
|
||||||
desc="delete_push_rule",
|
desc="delete_push_rule",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.get_push_rules_for_user.invalidate(user_name)
|
||||||
self.get_push_rules_enabled_for_user.invalidate(user_name)
|
self.get_push_rules_enabled_for_user.invalidate(user_name)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
@ -228,7 +239,12 @@ class PushRuleStore(SQLBaseStore):
|
|||||||
{'enabled': 1 if enabled else 0},
|
{'enabled': 1 if enabled else 0},
|
||||||
{'id': new_id},
|
{'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):
|
class RuleNotFoundException(Exception):
|
||||||
|
Loading…
Reference in New Issue
Block a user