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

Commit

Permalink
Describe prune_unread_entries in docstrings (#11876)
Browse files Browse the repository at this point in the history
Should have been caught in #10826.
  • Loading branch information
David Robertson committed Feb 2, 2022
1 parent acda9f0 commit f510fba
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/11876.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve internal docstrings in `synapse.util.caches`.
5 changes: 3 additions & 2 deletions synapse/util/caches/deferred_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ def __init__(
Args:
name: The name of the cache
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
iterable: If True, count each item in the cached object as an entry,
rather than each cached object
apply_cache_factor_from_config: Whether cache factors specified in the
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

Expand Down
8 changes: 8 additions & 0 deletions synapse/util/caches/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,17 @@ def foo(self, key, cache_context):
return r1 + r2
Args:
orig:
max_entries:
num_args: number of positional arguments (excluding ``self`` and
``cache_context``) to use as cache keys. Defaults to all named
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__(
Expand Down
6 changes: 6 additions & 0 deletions synapse/util/caches/lrucache.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ def __init__(
apply_cache_factor_from_config (bool): If true, `max_size` will be
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
# `real_clock` so that mypy doesn't think its still `Optional`.
Expand Down

0 comments on commit f510fba

Please sign in to comment.