UNPKG

mastercache

Version:

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

80 lines (77 loc) 2.46 kB
import { BaseDriver } from '../base-driver.js'; import { C as CreateDriverResult } from '../../../mastercache-Di19srNZ.js'; import { FileConfig } from '../../types/options/drivers-options.js'; import { CacheDriver } from '../../types/driver.js'; import 'knex'; import 'kysely'; import '@aws-sdk/client-dynamodb'; import 'ioredis'; import 'orchid-orm'; import '../../types/helpers.js'; import 'typescript-log'; import '../../types/provider.js'; import '../../types/options/methods-options.js'; import '../../types/options/options.js'; import '../../../events-CkqPK7En.js'; import '../../types/bus.js'; import '@boringnode/bus/types/main'; /** * Caching driver for the filesystem * * - Each key is stored as a file in the filesystem. * - Each namespace is a folder created in the parent namespace * - Files are stored in the following format: [stringifiedValue, expireTimestamp] * - If the expireTimestamp is -1, the value should never expire */ declare class FileDriver extends BaseDriver implements CacheDriver { #private; type: "l2"; config: FileConfig; constructor(config: FileConfig, isNamespace?: boolean); /** * Check if a file exists at a given path or not */ pathExists(path: string): Promise<boolean>; /** * Returns a new instance of the driver namespaced */ namespace(namespace: string): FileDriver; /** * Get a value from the cache */ get(key: string): Promise<string | undefined>; /** * Get the value of a key and delete it * * Returns the value if the key exists, undefined otherwise */ pull(key: string): Promise<string | undefined>; /** * Put a value in the cache * Returns true if the value was set, false otherwise */ set(key: string, value: string, ttl?: number): Promise<boolean>; /** * Check if a key exists in the cache */ has(key: string): Promise<boolean>; /** * Remove all items from the cache */ clear(): Promise<void>; /** * Delete a key from the cache * Returns true if the key was deleted, false otherwise */ delete(key: string): Promise<boolean>; /** * Delete multiple keys from the cache */ deleteMany(keys: string[]): Promise<boolean>; disconnect(): Promise<void>; } /** * Create a new file driver */ declare function fileDriver(options: FileConfig): CreateDriverResult<FileDriver>; export { FileDriver, fileDriver };