Skip to content

Commit

Permalink
[main > release/client/2.0]: Add snapshot key in epoch tracker in ods…
Browse files Browse the repository at this point in the history
…p driver (#21898) (#21904)

## Description

Add snapshot key in epoch tracker in ODSP driver.

Co-authored-by: Jatin Garg <[email protected]>
  • Loading branch information
jatgarg and Jatin Garg authored Jul 24, 2024
1 parent efab53e commit 96906fd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/drivers/odsp-driver/src/epochTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
OdspErrorTypes,
maximumCacheDurationMs,
snapshotKey,
snapshotWithLoadingGroupIdKey,
} from "@fluidframework/odsp-driver-definitions/internal";
import {
ITelemetryLoggerExt,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 96906fd

Please sign in to comment.