@@ -116,35 +116,41 @@ def generate_config_section(self, **kwargs):
116116 #event_cache_size: 10K
117117
118118 caches:
119- # Controls the global cache factor, which is the default cache factor
120- # for all caches if a specific factor for that cache is not otherwise
121- # set.
122- #
123- # This can also be set by the "SYNAPSE_CACHE_FACTOR" environment
124- # variable. Setting by environment variable takes priority over
125- # setting through the config file.
126- #
127- # Defaults to 0.5, which will half the size of all caches.
128- #
129- #global_factor: 1.0
130-
131- # A dictionary of cache name to cache factor for that individual
132- # cache. Overrides the global cache factor for a given cache.
133- #
134- # These can also be set through environment variables comprised
135- # of "SYNAPSE_CACHE_FACTOR_" + the name of the cache in capital
136- # letters and underscores. Setting by environment variable
137- # takes priority over setting through the config file.
138- # Ex. SYNAPSE_CACHE_FACTOR_GET_USERS_WHO_SHARE_ROOM_WITH_USER=2.0
139- #
140- # Some caches have '*' and other characters that are not
141- # alphanumeric or underscores. These caches can be named with or
142- # without the special characters stripped. For example, to specify
143- # the cache factor for `*stateGroupCache*` via an environment
144- # variable would be `SYNAPSE_CACHE_FACTOR_STATEGROUPCACHE=2.0`.
145- #
146- per_cache_factors:
147- #get_users_who_share_room_with_user: 2.0
119+ # Controls the global cache factor, which is the default cache factor
120+ # for all caches if a specific factor for that cache is not otherwise
121+ # set.
122+ #
123+ # This can also be set by the "SYNAPSE_CACHE_FACTOR" environment
124+ # variable. Setting by environment variable takes priority over
125+ # setting through the config file.
126+ #
127+ # Defaults to 0.5, which will half the size of all caches.
128+ #
129+ #global_factor: 1.0
130+
131+ # A dictionary of cache name to cache factor for that individual
132+ # cache. Overrides the global cache factor for a given cache.
133+ #
134+ # These can also be set through environment variables comprised
135+ # of "SYNAPSE_CACHE_FACTOR_" + the name of the cache in capital
136+ # letters and underscores. Setting by environment variable
137+ # takes priority over setting through the config file.
138+ # Ex. SYNAPSE_CACHE_FACTOR_GET_USERS_WHO_SHARE_ROOM_WITH_USER=2.0
139+ #
140+ # Some caches have '*' and other characters that are not
141+ # alphanumeric or underscores. These caches can be named with or
142+ # without the special characters stripped. For example, to specify
143+ # the cache factor for `*stateGroupCache*` via an environment
144+ # variable would be `SYNAPSE_CACHE_FACTOR_STATEGROUPCACHE=2.0`.
145+ #
146+ per_cache_factors:
147+ #get_users_who_share_room_with_user: 2.0
148+
149+ # Controls how long an entry can be in a cache without having been
150+ # accessed before being evicted. Defaults to None, which means
151+ # entries are never evicted based on time.
152+ #
153+ #expiry_time: 30m
148154 """
149155
150156 def read_config (self , config , ** kwargs ):
@@ -200,6 +206,12 @@ def read_config(self, config, **kwargs):
200206 e .message # noqa: B306, DependencyException.message is a property
201207 )
202208
209+ expiry_time = cache_config .get ("expiry_time" )
210+ if expiry_time :
211+ self .expiry_time_msec = self .parse_duration (expiry_time )
212+ else :
213+ self .expiry_time_msec = None
214+
203215 # Resize all caches (if necessary) with the new factors we've loaded
204216 self .resize_all_caches ()
205217
0 commit comments