Cache
import { Cache } from "@hyper-fetch/core"
Description
Cache class handles the data exchange with the dispatchers.
Defined in cache/cache.ts:23
Parameters
Properties
events
events
Description
Defined in cache/cache.ts:25
Type
{ emitCacheData: <Response,Error>(cacheKey: string, data: CacheValueType<Response, Error>) => void; emitRevalidation: (cacheKey: string) => void; onData: <Response,Error>(cacheKey: string, callback: (data: CacheValueType<Response, Error>) => void) => VoidFunction; onRevalidate: (cacheKey: string, callback: () => void) => VoidFunction }
Methods
clear()
clear()
Preview
clear()
Description
Clear cache storages
Defined in cache/cache.ts:228
Return
Promise<void>
delete()
delete()
Preview
delete(cacheKey)
Description
Delete record from storages and trigger revalidation
Defined in cache/cache.ts:119
Parameters
Name | Details |
---|---|
cacheKey
|
|
Return
void
get()
get()
Preview
get<Response, Error>(cacheKey)
Description
Get particular record from storage by cacheKey. It will trigger lazyStorage to emit lazy load event for reading it's data.
Defined in cache/cache.ts:99
Parameters
Name | Details |
---|---|
cacheKey
|
|
Return
{
cacheTime: number;
clearKey: string;
data: [GenericDataType | null, GenericErrorType | null, number | null];
details: {
isCanceled: boolean;
isFailed: boolean;
isOffline: boolean;
retries: number;
timestamp: number;
};
garbageCollection: number;
}
getLazyKeys()
getLazyKeys()
Preview
getLazyKeys()
Description
Used to receive keys from sync storage and lazy storage
Defined in cache/cache.ts:185
Return
Promise<string[]>
getLazyResource()
getLazyResource()
Preview
getLazyResource<Response, Error>(cacheKey)
Description
Used to receive data from lazy storage
Defined in cache/cache.ts:152
Parameters
Name | Details |
---|---|
cacheKey
|
|
Return
Promise<CacheValueType<Response, Error>>
keys()
keys()
Preview
keys()
Description
Get sync storage keys, lazyStorage keys will not be included
Defined in cache/cache.ts:109
Return
string[]
revalidate()
revalidate()
Preview
revalidate(cacheKey)
Description
Revalidate cache by cacheKey or partial matching with RegExp
Defined in cache/cache.ts:130
Parameters
Name | Details |
---|---|
cacheKey
|
|
Return
Promise<void>
scheduleGarbageCollector()
scheduleGarbageCollector()
Preview
scheduleGarbageCollector(cacheKey)
Description
Schedule garbage collection for given key
Defined in cache/cache.ts:198
Parameters
Name | Details |
---|---|
cacheKey
|
|
Return
Promise<void>
set()
set()
Preview
set<Response, Error>(command, response, details)
Description
Set the cache data to the storage
Defined in cache/cache.ts:61
Parameters
Name | Details |
---|---|
command
|
|
response
|
|
details
|
|
Return
void