From 96906fdb1040dfaf8ead5fd6de85d33d6d6e4cc6 Mon Sep 17 00:00:00 2001 From: Jatin Garg <48029724+jatgarg@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:55:26 -0700 Subject: [PATCH] [main > release/client/2.0]: Add snapshot key in epoch tracker in odsp driver (#21898) (#21904) ## Description Add snapshot key in epoch tracker in ODSP driver. Co-authored-by: Jatin Garg --- packages/drivers/odsp-driver/src/epochTracker.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/drivers/odsp-driver/src/epochTracker.ts b/packages/drivers/odsp-driver/src/epochTracker.ts index dedaef7b9085..48060b6e5018 100644 --- a/packages/drivers/odsp-driver/src/epochTracker.ts +++ b/packages/drivers/odsp-driver/src/epochTracker.ts @@ -21,6 +21,7 @@ import { OdspErrorTypes, maximumCacheDurationMs, snapshotKey, + snapshotWithLoadingGroupIdKey, } from "@fluidframework/odsp-driver-definitions/internal"; import { ITelemetryLoggerExt, @@ -146,7 +147,7 @@ export class EpochTracker implements IPersistedFileCache { } // Expire the cached snapshot if it's older than snapshotCacheExpiryTimeoutMs and immediately // expire all old caches that do not have cacheEntryTime - if (entry.type === snapshotKey) { + if (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access const cacheTime = value.value?.cacheEntryTime; const currentTime = Date.now(); @@ -177,7 +178,7 @@ export class EpochTracker implements IPersistedFileCache { assert(this._fluidEpoch !== undefined, 0x1dd /* "no epoch" */); // For snapshots, the value should have the cacheEntryTime. // This will be used to expire snapshots older than snapshotCacheExpiryTimeoutMs. - if (entry.type === snapshotKey) { + if (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access value.cacheEntryTime = value.cacheEntryTime ?? Date.now(); } @@ -519,7 +520,7 @@ export class EpochTrackerWithRedemption extends EpochTracker { let result = super.get(entry); // equivalence of what happens in fetchAndParseAsJSON() - if (entry.type === snapshotKey) { + if (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) { result = result .then((value) => { // If there is nothing in cache, we need to wait for network call to complete (and do redemption)