Skip to content

Commit c5c65e5

Browse files
authored
Clear configuration store before loading new config (#54)
1 parent 954b86b commit c5c65e5

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eppo/node-server-sdk",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "Eppo node server SDK",
55
"main": "dist/index.js",
66
"files": [

src/configuration-store.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,17 @@ describe('InMemoryConfigurationStore', () => {
1616
expect(store.get(`key-${i}`)).toEqual(`value-${i}`);
1717
}
1818
});
19+
20+
it('evicts entries when new entries are loaded', () => {
21+
const maxSize = 1000;
22+
const store = new InMemoryConfigurationStore(maxSize);
23+
24+
store.setEntries({ "hello": "world", "bye": "world"});
25+
expect(store.get("hello")).toEqual("world");
26+
expect(store.get("bye")).toEqual("world");
27+
28+
store.setEntries({ "hello": "world"});
29+
expect(store.get("hello")).toEqual("world");
30+
expect(store.get("bye")).toEqual(null);
31+
})
1932
});

src/configuration-store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class InMemoryConfigurationStore implements IConfigurationStore {
2626
}
2727

2828
setEntries<T>(entries: Record<string, T>) {
29+
this.cache.clear();
2930
Object.entries(entries).forEach(([key, val]) => {
3031
this.cache.set(key, val);
3132
});

0 commit comments

Comments
 (0)