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

Commit d3daac7

Browse files
backporting fix to stale configuration cache to v1.x.y branch (#39)
* clear config store before loading new config (#30) * bump version v1.3.2 * migrate cherry picked test case to RAC-format --------- Co-authored-by: Sven Schmit <[email protected]>
1 parent a52c582 commit d3daac7

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

eppo_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from eppo_client.http_client import HttpClient, SdkParams
1111
from eppo_client.read_write_lock import ReadWriteLock
1212

13-
__version__ = "1.3.1"
13+
__version__ = "1.3.2"
1414

1515
__client: Optional[EppoClient] = None
1616
__lock = ReadWriteLock()

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
@@ -39,3 +39,16 @@ def test_evicts_old_entries_when_max_size_exceeded():
3939
assert (
4040
store.get_configuration("test-entry-{}".format(TEST_MAX_SIZE - 1)) == test_exp
4141
)
42+
43+
44+
def test_evicts_old_entries_when_setting_new_flags():
45+
store: ConfigurationStore[str] = ConfigurationStore(max_size=TEST_MAX_SIZE)
46+
47+
store.set_configurations({"flag": test_exp, "second_flag": test_exp})
48+
assert store.get_configuration("flag") == test_exp
49+
assert store.get_configuration("second_flag") == test_exp
50+
51+
# Updating the flags should evict flags that no longer exist
52+
store.set_configurations({"flag": test_exp})
53+
assert store.get_configuration("flag") == test_exp
54+
assert store.get_configuration("second_flag") is None

0 commit comments

Comments
 (0)