This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Enable cache time-based expiry by default #11849
Merged
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f798aba
make using cache expiry the default behavior
H-Shay adbd8ed
newsfragment
H-Shay bdeaf52
update comment
H-Shay 83661c5
newsfragment and update sample config
H-Shay 4eb3e6a
add boolean flag, rename expiry time
H-Shay 652c620
regenerate sample config
H-Shay 6784e1e
requested changes
H-Shay 253edca
Merge branch 'develop' into shay/default_expiry
H-Shay 775cbf7
add note in upgrade notes about changes
H-Shay 6dddbc7
lint
H-Shay 8efac83
renew sample config
H-Shay c86e536
follow config code style
H-Shay 327ea5a
follow config code style
H-Shay 8d06aac
regenerate sample config
H-Shay f37e95f
requested changes
H-Shay 3299583
d'oh! lints
H-Shay 77ac0d7
cleanup v1 header and reword flags
H-Shay 604145a
Merge branch 'develop' into shay/default_expiry
H-Shay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Enable cache time-based expiry by default. The `expiry_time` config flag will be superseded by `expire_caches` and `cache_entry_ttl`. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,7 @@ process, for example: | |
``` | ||
# Upgrading to v1.(next) | ||
|
||
|
||
## Stablisation of MSC3231 | ||
|
||
The unstable validity-check endpoint for the | ||
|
@@ -102,6 +103,14 @@ Please update any relevant reverse proxy or firewall configurations appropriatel | |
|
||
# Upgrading to v1.53.0 | ||
|
||
## Time-based cache expiry is now enabled by default | ||
|
||
Formerly, entries in the cache were not evicted regardless of whether they were accessed after storing. | ||
This behavior has now changed. By default entries in the cache are now evicted after 30m of not being accessed. | ||
To change the default behavior, go to the `caches` section of the config and change the `expire_caches` and | ||
`cache_entry_ttl` flags as necessary. Please note that these flags replace the `expiry_time` flag in the config. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth mentioning that |
||
|
||
|
||
## Dropping support for `webclient` listeners and non-HTTP(S) `web_client_location` | ||
|
||
Per the deprecation notice in Synapse v1.51.0, listeners of type `webclient` | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import logging | ||
import os | ||
import re | ||
import threading | ||
|
@@ -23,6 +24,8 @@ | |
|
||
from ._base import Config, ConfigError | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# The prefix for all cache factor-related environment variables | ||
_CACHE_PREFIX = "SYNAPSE_CACHE_FACTOR" | ||
|
||
|
@@ -148,11 +151,16 @@ def generate_config_section(self, **kwargs) -> str: | |
per_cache_factors: | ||
#get_users_who_share_room_with_user: 2.0 | ||
|
||
# Controls how long an entry can be in a cache without having been | ||
# accessed before being evicted. Defaults to None, which means | ||
# entries are never evicted based on time. | ||
# Controls whether cache entries are evicted after a specified time | ||
# period. Defaults to true. Uncomment to disable this feature. | ||
# | ||
#expire_caches: false | ||
|
||
# If expire_caches is enabled, this flag controls how long an entry can | ||
# be in a cache without having been accessed before being evicted. | ||
# Defaults to 30m. Uncomment to set a different time to live for cache entries. | ||
# | ||
#expiry_time: 30m | ||
#cache_entry_ttl: 30m | ||
|
||
# Controls how long the results of a /sync request are cached for after | ||
# a successful response is returned. A higher duration can help clients with | ||
|
@@ -217,12 +225,30 @@ def read_config(self, config, **kwargs) -> None: | |
e.message # noqa: B306, DependencyException.message is a property | ||
) | ||
|
||
expiry_time = cache_config.get("expiry_time") | ||
if expiry_time: | ||
self.expiry_time_msec: Optional[int] = self.parse_duration(expiry_time) | ||
expire_caches = cache_config.get("expire_caches", True) | ||
cache_entry_ttl = cache_config.get("cache_entry_ttl", "30m") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're changing config options, we should include backwards-compatibility support for the previous config option name. Thus if someone set |
||
if expire_caches: | ||
self.expiry_time_msec: Optional[int] = self.parse_duration(cache_entry_ttl) | ||
else: | ||
self.expiry_time_msec = None | ||
|
||
# Backwards compatibility support for the now-removed "expiry_time" config flag. | ||
expiry_time = cache_config.get("expiry_time") | ||
|
||
if expiry_time and expire_caches: | ||
logger.warning( | ||
"You have set two incompatible flags, expiry_time and expire_caches. Please only use the " | ||
"expire_caches and cache_entry_ttl flags and delete the expiry_time flag as it is " | ||
"deprecated." | ||
) | ||
if expiry_time: | ||
logger.warning( | ||
"Expiry_time is a deprecated flag, please use the expire_caches and cache_entry_ttl flags " | ||
"instead." | ||
) | ||
self.expiry_time_msec = self.parse_duration(expiry_time) | ||
|
||
self.sync_response_cache_duration = self.parse_duration( | ||
cache_config.get("sync_response_cache_duration", 0) | ||
) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably be a
.feature
?and "will be" should be "has been"?