import { AdapterInstance, ResponseType } from '../adapter'; import { ResponseDetailsType } from '../managers'; import { ClientInstance } from '../client'; import { CacheOptionsType, CacheAsyncStorageType, CacheStorageType, CacheValueType, CacheSetState, RequestCacheType, getCacheEvents } from '.'; import { RequestInstance } from '../request'; import { ExtractAdapterType, ExtractErrorType, ExtractResponseType } from '../types'; import { EventEmitter } from '../utils'; /** * Cache class handles the data exchange with the dispatchers. * * @note * Keys used to save the values are created dynamically on the Request class * */ export declare class Cache { options?: CacheOptionsType | undefined; emitter: EventEmitter; events: ReturnType; storage: CacheStorageType; lazyStorage?: CacheAsyncStorageType; version: string; garbageCollectors: Map; private logger; private client; constructor(options?: CacheOptionsType | undefined); initialize: (client: ClientInstance<{ adapter: Adapter; }>) => this; /** * Set the cache data to the storage * @param request * @param response * @returns */ set: >(request: Request, response: CacheSetState, ExtractErrorType, ExtractAdapterType> & ResponseDetailsType> & { hydrated?: boolean; }) => void; /** * Update the cache data with partial response data * @param request * @param partialResponse * @param isTriggeredExtrenally - informs whether an update was triggered due to internal logic or externally, e.g. * via plugin. * @returns */ update: >(request: Request, partialResponse: CacheSetState, ExtractErrorType, ExtractAdapterType> & ResponseDetailsType>>) => void; /** * Get particular record from storage by cacheKey. It will trigger lazyStorage to emit lazy load event for reading it's data. * @param cacheKey * @returns */ get: (cacheKey: string) => CacheValueType | undefined; /** * Get sync storage keys, lazyStorage keys will not be included * @returns */ keys: () => string[]; /** * Delete record from storages and trigger invalidation event * @param cacheKey */ delete: (cacheKey: string) => void; /** * Invalidate cache by cacheKey or partial matching with RegExp * It emits invalidation event for each matching cacheKey and sets staleTime to 0 to indicate out of time cache * @param key - cacheKey or Request instance or RegExp for partial matching */ invalidate: (cacheKeys: string | RegExp | RequestInstance | Array) => void; /** * Used to receive data from lazy storage * @param cacheKey */ getLazyResource: (cacheKey: string) => Promise | undefined>; /** * Used to receive keys from sync storage and lazy storage * @param cacheKey */ getLazyKeys: () => Promise; /** * Used to receive keys from sync storage and lazy storage * @param cacheKey */ getAllKeys: () => Promise; /** * Schedule garbage collection for given key * @param cacheKey * @returns */ scheduleGarbageCollector: (cacheKey: string) => void; /** * Clear cache storages */ clear: () => Promise; } //# sourceMappingURL=cache.d.ts.map