UNPKG

mastercache

Version:

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

32 lines (29 loc) 973 B
export { Logger } from 'typescript-log'; /** * A Duration can be a number in milliseconds or a string formatted as a duration * * Formats accepted are : * - Simple number in milliseconds * - String formatted as a duration. Uses https://github.com/lukeed/ms under the hood */ type Duration = number | string | null | undefined; /** * A factory is a function that returns a value or a promise of a value */ type MaybePromise<T> = T | Promise<T>; /** * A Factory is basically just a function that returns a value */ type Factory<T = any> = T | (() => T) | Promise<T> | (() => Promise<T>); type GetSetFactoryOptions = { /** * Set dynamically the TTL * See Adaptive caching documentation for more information */ setTtl: (ttl: Duration) => void; }; /** * GetOrSet Factory */ type GetSetFactory<T = any> = (options: GetSetFactoryOptions) => T | Promise<T>; export type { Duration, Factory, GetSetFactory, GetSetFactoryOptions, MaybePromise };