Skip to content

Commit 2f06186

Browse files
committed
added comment
1 parent 0b0ccc4 commit 2f06186

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

packages/open-next/src/overrides/incrementalCache/multi-tier-ddb-s3.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ const multiTierCache: IncrementalCache = {
100100
}
101101
return result;
102102
},
103+
104+
// Both for set and delete we choose to do the write to S3 first and then to DynamoDB
105+
// Which means that if it fails in DynamoDB, instance that don't have local cache will work as expected.
106+
// But instance that have local cache will have a stale cache until the next working set or delete.
103107
async set(key, value, isFetch) {
104108
const revalidatedAt = Date.now();
105109
await S3Cache.set(key, value, isFetch);

packages/open-next/src/utils/lru.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export class LRUCache<T> {
55

66
get(key: string) {
77
const result = this.cache.get(key);
8+
// We could have used .has to allow for nullish value to be stored but we don't need that right now
89
if (result) {
10+
// By removing and setting the key again we ensure it's the most recently used
911
this.cache.delete(key);
1012
this.cache.set(key, result);
1113
}

0 commit comments

Comments
 (0)