Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit d663582

Browse files
authored
clear config store before loading new config (#30)
1 parent d7cba6b commit d663582

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

eppo_client/configuration_store.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def get_configuration(self, key: str) -> Optional[T]:
2323
def set_configurations(self, configs: Dict[str, T]):
2424
try:
2525
self.__lock.acquire_write()
26+
self.__cache.clear()
2627
for key, config in configs.items():
2728
self.__cache[key] = config
2829
finally:

test/configuration_store_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,16 @@ def test_evicts_old_entries_when_max_size_exceeded():
3737
assert (
3838
store.get_configuration("test-entry-{}".format(TEST_MAX_SIZE - 1)) == mock_flag
3939
)
40+
41+
42+
def test_evicts_old_entries_when_setting_new_flags():
43+
store: ConfigurationStore[str] = ConfigurationStore(max_size=TEST_MAX_SIZE)
44+
45+
store.set_configurations({"flag": mock_flag, "second_flag": mock_flag})
46+
assert store.get_configuration("flag") == mock_flag
47+
assert store.get_configuration("second_flag") == mock_flag
48+
49+
# Updating the flags should evict flags that no longer exist
50+
store.set_configurations({"flag": mock_flag})
51+
assert store.get_configuration("flag") == mock_flag
52+
assert store.get_configuration("second_flag") is None

0 commit comments

Comments
 (0)