UNPKG

mastercache

Version:

Multi-tier cache module for Node.js. Redis, Upstash, CloudfareKV, File, in-memory and others drivers

78 lines (75 loc) 2.39 kB
import { GetSetFactory, Factory } from '../helpers.js'; import { RawCommonOptions } from './options.js'; import 'typescript-log'; import '../../../events-CkqPK7En.js'; import '../bus.js'; import '@boringnode/bus/types/main'; /** * Options accepted by the `getOrSet` method */ type GetOrSetOptions = Pick<RawCommonOptions, 'earlyExpiration' | 'gracePeriod' | 'suppressL2Errors' | 'lockTimeout' | 'ttl' | 'timeouts'>; /** * Options accepted by the `getOrSet` method when passing an object */ type GetOrSetPojoOptions<T> = { key: string; factory: GetSetFactory<T>; } & GetOrSetOptions; /** * Options accepted by the `getOrSetForever` method */ type GetOrSetForeverOptions = Pick<RawCommonOptions, 'earlyExpiration' | 'gracePeriod' | 'suppressL2Errors' | 'lockTimeout' | 'timeouts'>; /** * Options accepted by the `getOrSetForever` method when passing an object */ type GetOrSetForeverPojoOptions<T> = { key: string; factory: GetSetFactory<T>; } & GetOrSetForeverOptions; /** * Options accepted by the `set` method */ type SetOptions = GetOrSetOptions; type SetPojoOptions = { key: string; value: any; } & SetOptions; /** * Options accepted by the `get` method */ type GetOptions = Pick<RawCommonOptions, 'earlyExpiration' | 'gracePeriod' | 'suppressL2Errors'>; /** * Options accepted by the `get` method when passing an object */ type GetPojoOptions<T> = { key: string; defaultValue?: Factory<T>; } & GetOptions; /** * Options accepted by the `delete` method */ type DeleteOptions = Pick<RawCommonOptions, 'suppressL2Errors'>; /** * Options accepted by the `delete` method when passing an object */ type DeletePojoOptions = { key: string; } & DeleteOptions; type DeleteManyPojoOptions = { keys: string[]; } & DeleteOptions; /** * Options accepted by the `has` method */ type HasOptions = Pick<RawCommonOptions, 'suppressL2Errors'>; /** * Options accepted by the `has` method when passing an object */ type HasPojoOptions = { key: string; } & HasOptions; /** * Options accepted by the `clear` method */ type ClearOptions = Pick<RawCommonOptions, 'suppressL2Errors'>; export type { ClearOptions, DeleteManyPojoOptions, DeleteOptions, DeletePojoOptions, GetOptions, GetOrSetForeverOptions, GetOrSetForeverPojoOptions, GetOrSetOptions, GetOrSetPojoOptions, GetPojoOptions, HasOptions, HasPojoOptions, SetOptions, SetPojoOptions };