Skip to content

Commit

Permalink
Merge 5065b9a into 3b4d546
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] committed Feb 24, 2022
2 parents 3b4d546 + 5065b9a commit 742fcf4
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 30 deletions.
116 changes: 100 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
"typescript": "^4.2.4"
},
"dependencies": {
"@types/lru-cache": "^5.1.0",
"lru-cache": "^6.0.0"
"@types/lru-cache": "^7.4.0",
"lru-cache": "^7.4.0"
},
"peerDependencies": {
"boardgame.io": ">=0.41.1"
Expand Down
16 changes: 8 additions & 8 deletions src/bgio-storage-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export class StorageCache extends Async {
initialState: new LRU({ max: cacheSize }),
log: new LRU({ max: cacheSize }),
reset: (): void => {
this.cache.metadata.reset();
this.cache.state.reset();
this.cache.initialState.reset();
this.cache.log.reset();
this.cache.metadata.clear();
this.cache.state.clear();
this.cache.initialState.clear();
this.cache.log.clear();
},
};
}
Expand Down Expand Up @@ -190,10 +190,10 @@ export class StorageCache extends Async {
*/
async wipe(gameID: string): Promise<void> {
await this.db.wipe(gameID);
this.cache.metadata.del(gameID);
this.cache.state.del(gameID);
this.cache.initialState.del(gameID);
this.cache.log.del(gameID);
this.cache.metadata.delete(gameID);
this.cache.state.delete(gameID);
this.cache.initialState.delete(gameID);
this.cache.log.delete(gameID);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions test/bgio-storage-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ describe('StorageCache', () => {
await db.connect();
await db.setState('gameID', { a: 1 } as unknown as State);
await db.setState('another', { b: 1 } as unknown as State);
expect(db.cache.state.itemCount).toBe(1);
expect(db.cache.state.keys()).toEqual(['another']);
expect(db.cache.state.size).toBe(1);
expect([...db.cache.state.keys()]).toEqual(['another']);
});

test('race conditions', async () => {
Expand Down Expand Up @@ -341,8 +341,8 @@ describe('StorageCache with a deprecated database connector', () => {
await db.connect();
await db.setState('gameID', { a: 1 } as unknown as State);
await db.setState('another', { b: 1 } as unknown as State);
expect(db.cache.state.itemCount).toBe(1);
expect(db.cache.state.keys()).toEqual(['another']);
expect(db.cache.state.size).toBe(1);
expect([...db.cache.state.keys()]).toEqual(['another']);
});

test('race conditions', async () => {
Expand Down

0 comments on commit 742fcf4

Please sign in to comment.