@figmarine/cache
Version:
Library to cache arbitrary data to disk for arbitrarily long
29 lines (26 loc) • 720 B
TypeScript
import { Cacheable } from 'cacheable';
import { Keyv } from 'keyv';
/**
* Options for the {@link makeCache} function.
*/
interface MakeCacheOptions {
/**
* Path to where the cache must be stored. If the path is relative,
* then the cache is written to `/tmp/@figmarine/cache/${location}`.
* @type {string}
*/
location: string;
/**
* TTL, in seconds, for the cache.
* Pass -1 to keep files for as long as a year.
* @type {number}
* @default 10
*/
ttl?: number;
}
declare function makeCache(opts: MakeCacheOptions): {
cache: Cacheable;
primary: Keyv<any>;
shutdownGracefully: () => Promise<void>;
};
export { type MakeCacheOptions, makeCache };