Don't apply cache factor to event cache. (#7578)

This is already correctly done when we instansiate the cache, but wasn't
when it got reloaded (which always happens at least once on startup).
This commit is contained in:
Erik Johnston 2020-05-27 12:04:37 +01:00 committed by GitHub
parent 9bac5d62b3
commit eefc6b3a0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View file

@ -125,3 +125,19 @@ class CacheConfigTests(TestCase):
cache = LruCache(100)
add_resizable_cache("foo", cache_resize_callback=cache.set_cache_factor)
self.assertEqual(cache.max_size, 150)
def test_apply_cache_factor_from_config(self):
"""Caches can disable applying cache factor updates, mainly used by
event cache size.
"""
config = {"caches": {"event_cache_size": "10k"}}
t = TestConfig()
t.read_config(config, config_dir_path="", data_dir_path="")
cache = LruCache(
max_size=t.caches.event_cache_size, apply_cache_factor_from_config=False,
)
add_resizable_cache("event_cache", cache_resize_callback=cache.set_cache_factor)
self.assertEqual(cache.max_size, 10240)