AIDC Toolkit / Core / Cache
Abstract Class: Cache<TCache, TSource>
Defined in: cache.ts:12
Generic cache. Typically used to manage a local copy of remote data that is not refreshed regularly.
Type Parameters
TCache
TCache
Type of cached data.
TSource
TSource = TCache
Type of source data. The type may be different from the cached data type if a transformation is required.
Constructors
Constructor
new Cache<
TCache,TSource>():Cache<TCache,TSource>
Returns
Cache<TCache, TSource>
Accessors
nextCheckDateTime
Get Signature
get
abstractnextCheckDateTime():Promisable<Date|undefined>
Defined in: cache.ts:17
Get the date/time at or after which the source should be checked for updates. If the value is undefined, this is the first usage.
Returns
Promisable<Date | undefined>
cacheDateTime
Get Signature
get
abstractcacheDateTime():Promisable<Date|undefined>
Defined in: cache.ts:23
Get the date/time at which the cache was last updated. This may more accurately reflect the date/time at which the last source retrieved was updated. If the value is undefined, there is no data in the cache.
Returns
Promisable<Date | undefined>
cacheData
Get Signature
get
abstractcacheData():Promisable<TCache>
Defined in: cache.ts:28
Get the cache data. This should only ever be called if the cache date/time is defined.
Returns
Promisable<TCache>
sourceDateTime
Get Signature
get
abstractsourceDateTime():Promisable<Date>
Defined in: cache.ts:34
Get the date/time at which the source was last updated. This should not be called unless the next check date/time has passed, as it may trigger an expensive remote retrieval.
Returns
sourceData
Get Signature
get
abstractsourceData():Promisable<TSource>
Defined in: cache.ts:40
Get the source data. This should not be called unless the next check date/time has passed, as it may trigger an expensive remote retrieval.
Returns
Promisable<TSource>
Methods
update()
Call Signature
abstractupdate(nextCheckDateTime):Promisable<void>
Defined in: cache.ts:49
Update the cache with only the next check date/time. The cache date/time and cache data must not be modified. This is typically called when the cache is up to date with the source or source retrieval has failed.
Parameters
nextCheckDateTime
Next check date/time.
Returns
Promisable<void>
Call Signature
abstractupdate(nextCheckDateTime,cacheDateTime,cacheData):Promisable<void>
Defined in: cache.ts:63
Update all cache parameters. This is typically called when the cache is updated from the source.
Parameters
nextCheckDateTime
Next check date/time.
cacheDateTime
Cache date/time.
cacheData
TCache
Cache data.
Returns
Promisable<void>