bentocache
Version:
Multi-tier cache module for Node.js. Redis, Upstash, CloudfareKV, File, in-memory and others drivers
71 lines (68 loc) • 2.16 kB
TypeScript
import { BaseDriver } from '../base_driver.js';
import { a as CreateDriverResult } from '../../../index-Cd7wE4bj.js';
import { F as FileConfig } from '../../../drivers_options-Dm62iGEe.js';
import { C as CacheDriver } from '../../../driver-CldynQv4.js';
import '@poppinss/exception';
import '@boringnode/bus/types/main';
import '@julr/utils/logger';
import 'knex';
import 'kysely';
import '@aws-sdk/client-dynamodb';
import 'ioredis';
import 'orchid-orm';
/**
* Create a new file driver
*/
declare function fileDriver(options: FileConfig): CreateDriverResult<FileDriver>;
/**
* 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);
/**
* 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>;
}
export { FileDriver, fileDriver };