Describe prune_unread_entries in docstrings (#11876)

Should have been caught in #10826.
This commit is contained in:
David Robertson 2022-02-02 15:11:23 +00:00 committed by GitHub
parent acda9f07c8
commit f510fba4ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 2 deletions

1
changelog.d/11876.misc Normal file
View File

@ -0,0 +1 @@
Improve internal docstrings in `synapse.util.caches`.

View File

@ -81,13 +81,14 @@ class DeferredCache(Generic[KT, VT]):
Args: Args:
name: The name of the cache name: The name of the cache
max_entries: Maximum amount of entries that the cache will hold max_entries: Maximum amount of entries that the cache will hold
keylen: The length of the tuple used as the cache key. Ignored unless
`tree` is True.
tree: Use a TreeCache instead of a dict as the underlying cache type tree: Use a TreeCache instead of a dict as the underlying cache type
iterable: If True, count each item in the cached object as an entry, iterable: If True, count each item in the cached object as an entry,
rather than each cached object rather than each cached object
apply_cache_factor_from_config: Whether cache factors specified in the apply_cache_factor_from_config: Whether cache factors specified in the
config file affect `max_entries` config file affect `max_entries`
prune_unread_entries: If True, cache entries that haven't been read recently
will be evicted from the cache in the background. Set to False to
opt-out of this behaviour.
""" """
cache_type = TreeCache if tree else dict cache_type = TreeCache if tree else dict

View File

@ -254,9 +254,17 @@ class DeferredCacheDescriptor(_CacheDescriptorBase):
return r1 + r2 return r1 + r2
Args: Args:
orig:
max_entries:
num_args: number of positional arguments (excluding ``self`` and num_args: number of positional arguments (excluding ``self`` and
``cache_context``) to use as cache keys. Defaults to all named ``cache_context``) to use as cache keys. Defaults to all named
args of the function. args of the function.
tree:
cache_context:
iterable:
prune_unread_entries: If True, cache entries that haven't been read recently
will be evicted from the cache in the background. Set to False to opt-out
of this behaviour.
""" """
def __init__( def __init__(

View File

@ -340,6 +340,12 @@ class LruCache(Generic[KT, VT]):
apply_cache_factor_from_config (bool): If true, `max_size` will be apply_cache_factor_from_config (bool): If true, `max_size` will be
multiplied by a cache factor derived from the homeserver config multiplied by a cache factor derived from the homeserver config
clock:
prune_unread_entries: If True, cache entries that haven't been read recently
will be evicted from the cache in the background. Set to False to
opt-out of this behaviour.
""" """
# Default `clock` to something sensible. Note that we rename it to # Default `clock` to something sensible. Note that we rename it to
# `real_clock` so that mypy doesn't think its still `Optional`. # `real_clock` so that mypy doesn't think its still `Optional`.