File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
overrides/incrementalCache Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -50,9 +50,15 @@ const buildDynamoKey = (key: string) => {
5050 */
5151const multiTierCache : IncrementalCache = {
5252 name : "multi-tier-ddb-s3" ,
53- async get ( key , isFetch ) {
53+ async get < IsFetch extends boolean = false > ( key : string , isFetch ?: IsFetch ) {
5454 // First we check the local cache
55- const localCacheEntry = localCache . get ( key ) ;
55+ const localCacheEntry = localCache . get ( key ) as
56+ | {
57+ value : CacheValue < IsFetch > ;
58+ lastModified : number ;
59+ }
60+ | undefined ;
61+
5662 if ( localCacheEntry ) {
5763 if ( Date . now ( ) - localCacheEntry . lastModified < localCacheTTL ) {
5864 debug ( "Using local cache without checking ddb" ) ;
Original file line number Diff line number Diff line change @@ -75,8 +75,12 @@ export type WithLastModified<T> = {
7575 value ?: T ;
7676} ;
7777
78+ export function isFetchPredicate ( value : CacheValue < boolean > ) : value is CacheValue < true > {
79+ return "kind" in value ;
80+ }
81+
7882export type CacheValue < IsFetch extends boolean > = ( IsFetch extends true
79- ? Partial < CachedFetchValue >
83+ ? CachedFetchValue
8084 : CachedFile ) & { revalidate ?: number | false } ;
8185
8286export type IncrementalCache = {
You can’t perform that action at this time.
0 commit comments