Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eppo_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from eppo_client.http_client import HttpClient, SdkParams
from eppo_client.read_write_lock import ReadWriteLock

__version__ = "1.3.1"
__version__ = "1.3.2"

__client: Optional[EppoClient] = None
__lock = ReadWriteLock()
Expand Down
1 change: 1 addition & 0 deletions eppo_client/configuration_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def get_configuration(self, key: str) -> Optional[T]:
def set_configurations(self, configs: Dict[str, T]):
try:
self.__lock.acquire_write()
self.__cache.clear()
for key, config in configs.items():
self.__cache[key] = config
finally:
Expand Down
13 changes: 13 additions & 0 deletions test/configuration_store_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,16 @@ def test_evicts_old_entries_when_max_size_exceeded():
assert (
store.get_configuration("test-entry-{}".format(TEST_MAX_SIZE - 1)) == test_exp
)


def test_evicts_old_entries_when_setting_new_flags():
store: ConfigurationStore[str] = ConfigurationStore(max_size=TEST_MAX_SIZE)

store.set_configurations({"flag": test_exp, "second_flag": test_exp})
assert store.get_configuration("flag") == test_exp
assert store.get_configuration("second_flag") == test_exp

# Updating the flags should evict flags that no longer exist
store.set_configurations({"flag": test_exp})
assert store.get_configuration("flag") == test_exp
assert store.get_configuration("second_flag") is None