mastercache
Version:
Multi-tier cache module for Node.js. Redis, Upstash, CloudfareKV, File, in-memory and others drivers
80 lines (77 loc) • 2.47 kB
text/typescript
import { BaseDriver } from '../base-driver.cjs';
import { C as CreateDriverResult } from '../../../mastercache-CD6UEBYT.cjs';
import { FileConfig } from '../../types/options/drivers-options.cjs';
import { CacheDriver } from '../../types/driver.cjs';
import 'knex';
import 'kysely';
import '@aws-sdk/client-dynamodb';
import 'ioredis';
import 'orchid-orm';
import '../../types/helpers.cjs';
import 'typescript-log';
import '../../types/provider.cjs';
import '../../types/options/methods-options.cjs';
import '../../types/options/options.cjs';
import '../../../events-BJQnbTp3.cjs';
import '../../types/bus.cjs';
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 };