Skip to content

Commit

Permalink
Make odsp test cache less likely to fail (microsoft#22585)
Browse files Browse the repository at this point in the history
[AB#15994](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/15994)

Looking at the errors, it only looks like this occurred once. Based on
the error stack, I've made some improvements to the `TestSnapshotCache`
so that the persisted cache can be used for other non-snapshot storage,
and non-`ValueWithSnapshot` types can be stored.
  • Loading branch information
tyler-cai-microsoft authored Sep 27, 2024
1 parent 5989ab2 commit ed8bd72
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/test/test-end-to-end-tests/src/testSnapshotCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ export interface ValueWithSnapshot {
}

export class TestSnapshotCache implements IPersistedCache {
private readonly cache = new Map<string, ValueWithSnapshot>();
private readonly cache = new Map<string, unknown>();
private readonly versionCache = new Map<string, ValueWithSnapshot>();
private readonly versionToCacheKey = new Map<string, string>();
public async get(entry: ICacheEntry): Promise<ValueWithSnapshot | undefined> {
public async get(entry: ICacheEntry): Promise<any | undefined> {
const key = getKeyForCacheEntry(entry);
return this.cache.get(key);
}
public async put(entry: ICacheEntry, value: ValueWithSnapshot): Promise<void> {
public async put(entry: ICacheEntry, value: any): Promise<void> {
const key = getKeyForCacheEntry(entry);
this.cache.set(key, value);
if (value.value?.snapshotTree?.id === undefined) {
return;
}
const versionKey = `${value.value.snapshotTree.id}`;
this.versionCache.set(versionKey, value);
this.versionToCacheKey.set(versionKey, key);
Expand Down

0 comments on commit ed8bd72

Please sign in to comment.