mastercache
Version:
Multi-tier cache module for Node.js. Redis, Upstash, CloudfareKV, File, in-memory and others drivers
37 lines (31 loc) • 942 B
text/typescript
/**
* 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
*/
export type Duration = number | string | null | undefined
/**
* A factory is a function that returns a value or a promise of a value
*/
export type MaybePromise<T> = T | Promise<T>
/**
* A Factory is basically just a function that returns a value
*/
export type Factory<T = any> = T | (() => T) | Promise<T> | (() => Promise<T>)
export type GetSetFactoryOptions = {
/**
* Set dynamically the TTL
* See Adaptive caching documentation for more information
*/
setTtl: (ttl: Duration) => void
}
/**
* GetOrSet Factory
*/
export type GetSetFactory<T = any> = (options: GetSetFactoryOptions) => T | Promise<T>
/**
* Logger interface
*/
export type { Logger } from 'typescript-log';