mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 16:14:49 -04:00
Opt out of cache expiry for get_users_who_share_room_with_user
(#10826)
* Allow LruCaches to opt out of time-based expiry * Don't expire `get_users_who_share_room` & friends
This commit is contained in:
parent
80828eda06
commit
724aef9a87
5 changed files with 30 additions and 6 deletions
|
@ -202,10 +202,11 @@ class _Node:
|
|||
cache: "weakref.ReferenceType[LruCache]",
|
||||
clock: Clock,
|
||||
callbacks: Collection[Callable[[], None]] = (),
|
||||
prune_unread_entries: bool = True,
|
||||
):
|
||||
self._list_node = ListNode.insert_after(self, root)
|
||||
self._global_list_node = None
|
||||
if USE_GLOBAL_LIST:
|
||||
self._global_list_node: Optional[_TimedListNode] = None
|
||||
if USE_GLOBAL_LIST and prune_unread_entries:
|
||||
self._global_list_node = _TimedListNode.insert_after(self, GLOBAL_ROOT)
|
||||
self._global_list_node.update_last_access(clock)
|
||||
|
||||
|
@ -314,6 +315,7 @@ class LruCache(Generic[KT, VT]):
|
|||
metrics_collection_callback: Optional[Callable[[], None]] = None,
|
||||
apply_cache_factor_from_config: bool = True,
|
||||
clock: Optional[Clock] = None,
|
||||
prune_unread_entries: bool = True,
|
||||
):
|
||||
"""
|
||||
Args:
|
||||
|
@ -427,7 +429,15 @@ class LruCache(Generic[KT, VT]):
|
|||
self.len = synchronized(cache_len)
|
||||
|
||||
def add_node(key, value, callbacks: Collection[Callable[[], None]] = ()):
|
||||
node = _Node(list_root, key, value, weak_ref_to_self, real_clock, callbacks)
|
||||
node = _Node(
|
||||
list_root,
|
||||
key,
|
||||
value,
|
||||
weak_ref_to_self,
|
||||
real_clock,
|
||||
callbacks,
|
||||
prune_unread_entries,
|
||||
)
|
||||
cache[key] = node
|
||||
|
||||
if size_callback:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue