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

Commit

Permalink
Move cache invalidation to a single place.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Mar 9, 2022
1 parent ecbc2d9 commit f15a031
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions synapse/storage/databases/main/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,9 +1619,15 @@ def prefill():

txn.call_after(prefill)

def _store_redaction(self, txn, event):
# invalidate the cache for the redacted event
def _store_redaction(self, txn: LoggingTransaction, event: EventBase) -> None:
# invalidate the caches for the redacted event
txn.call_after(self.store._invalidate_get_event_cache, event.redacts)
self.store._invalidate_cache_and_stream(
txn, self.store.get_relations_for_event, (event.redacts,)
)
self.store._invalidate_cache_and_stream(
txn, self.store.get_applicable_edit, (event.redacts,)
)

self.db_pool.simple_upsert_txn(
txn,
Expand Down Expand Up @@ -1978,15 +1984,6 @@ def _handle_redact_relations(
txn, self.store.get_thread_participated, (redacted_relates_to,)
)

# Caches which might leak edits must be invalidated for the event being
# redacted.
self.store._invalidate_cache_and_stream(
txn, self.store.get_relations_for_event, (redacted_event_id,)
)
self.store._invalidate_cache_and_stream(
txn, self.store.get_applicable_edit, (redacted_event_id,)
)

self.db_pool.simple_delete_txn(
txn, table="event_relations", keyvalues={"event_id": redacted_event_id}
)
Expand Down

0 comments on commit f15a031

Please sign in to comment.