mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-13 20:32:48 -04:00
Allow for ignoring some arguments when caching. (#12189)
* `@cached` can now take an `uncached_args` which is an iterable of names to not use in the cache key. * Requires `@cached`, @cachedList` and `@lru_cache` to use keyword arguments for clarity. * Asserts that keyword-only arguments in cached functions are not accepted. (I tested this briefly and I don't believe this works properly.)
This commit is contained in:
parent
032688854b
commit
690cb4f3b3
4 changed files with 142 additions and 21 deletions
|
@ -1286,7 +1286,7 @@ class EventsWorkerStore(SQLBaseStore):
|
|||
)
|
||||
return {eid for ((_rid, eid), have_event) in res.items() if have_event}
|
||||
|
||||
@cachedList("have_seen_event", "keys")
|
||||
@cachedList(cached_method_name="have_seen_event", list_name="keys")
|
||||
async def _have_seen_events_dict(
|
||||
self, keys: Iterable[Tuple[str, str]]
|
||||
) -> Dict[Tuple[str, str], bool]:
|
||||
|
@ -1954,7 +1954,7 @@ class EventsWorkerStore(SQLBaseStore):
|
|||
get_event_id_for_timestamp_txn,
|
||||
)
|
||||
|
||||
@cachedList("is_partial_state_event", list_name="event_ids")
|
||||
@cachedList(cached_method_name="is_partial_state_event", list_name="event_ids")
|
||||
async def get_partial_state_events(
|
||||
self, event_ids: Collection[str]
|
||||
) -> Dict[str, bool]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue