UNPKG

@linkedmink/multilevel-aging-cache

Version:

Package provides an interface to cache and persist data to Redis, MongoDB, memory

35 lines 1.33 kB
import { IAgedValue } from '../queue/IAgedQueue'; import { IStorageProvider } from './IStorageProvider'; /** * A key/value storage system for local memory. This is essentially a wrapper of a Map */ export declare class MemoryStorageProvider<TKey, TValue> implements IStorageProvider<TKey, TValue> { private readonly data; readonly isPersistable = false; /** * @param key The key to retrieve * @returns The value if retreiving was successful or null */ get(key: TKey): Promise<IAgedValue<TValue> | null>; /** * @param key The key to set * @param value The value to set * @returns The value written if successful or null */ set(key: TKey, agedValue: IAgedValue<TValue>): Promise<IAgedValue<TValue> | null>; /** * @param key The key to the value to delete * @returns The value deleted or boolean (value | true is success). A provider * is not required to return a value */ delete(key: TKey): Promise<IAgedValue<TValue> | boolean>; /** * @returns The keys that are currently available in the provider */ keys(): Promise<TKey[]>; /** * @returns The number of elements in this storage system */ size(): Promise<number>; } //# sourceMappingURL=MemoryStorageProvider.d.ts.map