UNPKG

layered-loader

Version:

Data loader with support for caching and fallback data sources

25 lines (24 loc) 1.02 kB
import type { HitStatisticsRecord } from 'toad-cache'; import type { CommonCacheConfiguration } from '../types/DataSources'; import type { GetManyResult, SynchronousCache } from '../types/SyncDataSources'; type CacheTypeId = 'lru-map' | 'fifo-map' | 'lru-object' | 'fifo-object' | 'lru-object-statistics'; export interface InMemoryCacheConfiguration extends CommonCacheConfiguration { cacheId?: string; globalStatisticsRecord?: HitStatisticsRecord; cacheType?: CacheTypeId; maxItems?: number; } export declare class InMemoryCache<T> implements SynchronousCache<T> { private readonly cache; name: string; readonly ttlLeftBeforeRefreshInMsecs?: number; constructor(config: InMemoryCacheConfiguration); clear(): void; delete(key: string): void; deleteMany(keys: string[]): void; get(key: string): T | null | undefined; getMany(keys: string[]): GetManyResult<T>; getExpirationTime(key: string): number | undefined; set(key: string, value: T | null): void; } export {};