Constructors
constructor
- new StorageCache(storage, key, ms): StorageCache
Parameters
storage: Storage
key: string
ms: number
Properties
Private
#storage
#storage: Storage
Accessors
ms
- get ms(): number
Returns number
Methods
Private
#get
- #get(path): undefined | StoredItem<unknown>
Returns undefined | StoredItem<unknown>
Private
#keyMatches
- #keyMatches(pathKey, test): boolean
Parameters
pathKey: string
test: string
Returns boolean
Private
#pathKey
- #pathKey(path): string
Returns string
Private
#save
- #save(obj): void
Parameters
obj: Record<string, unknown>
Returns void
get
- get(path): unknown
Returns unknown
set
- set(path, value, ms?): void
Parameters
path: string[]
value: unknown
ms: number = ...
Returns void
timeLeft
- timeLeft(path): number
Returns number
unset
- unset(path): void
Returns void
updateIfStale
- updateIfStale(path, update, ms?): Promise<boolean>
Parameters
path: string[]
update: (() => unknown)
- (): unknown
Returns unknown
Optional
ms: number
Returns Promise<boolean>
Timed cache using a
Storage
interface.Example
Letting cache expire.
Example
Manually invalidating cache.