bentocache
Version:
Multi-tier cache module for Node.js. Redis, Upstash, CloudfareKV, File, in-memory and others drivers
64 lines (61 loc) • 1.78 kB
TypeScript
import { BaseDriver } from '../base_driver.js';
import { CacheDriver, DatabaseAdapter, DatabaseConfig } from '../../types/main.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';
/**
* A store that use a database to store cache entries
*
* You should provide an adapter that will handle the database interactions
*/
declare class DatabaseDriver extends BaseDriver implements CacheDriver<true> {
#private;
type: "l2";
constructor(adapter: DatabaseAdapter, config: DatabaseConfig, isNamespace?: boolean);
/**
* Returns a new instance of the driver namespaced
*/
namespace(namespace: string): any;
/**
* Get a value from the cache
*/
get(key: string): Promise<any>;
/**
* Get the value of a key and delete it
*
* Returns the value if the key exists, undefined otherwise
*/
pull(key: string): Promise<string | undefined>;
/**
* Set a value in the cache
* Returns true if the value was set, false otherwise
*/
set(key: string, value: any, ttl?: number): 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 from the database
*/
disconnect(): Promise<void>;
/**
* Manually prune expired cache entries.
*/
prune(): Promise<void>;
}
export { DatabaseDriver };