File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed
overrides/incrementalCache Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments