tspace-mysql
Version:
Tspace MySQL is a promise-based ORM for Node.js, designed with modern TypeScript and providing type safety for schema databases.
57 lines (56 loc) • 1.5 kB
TypeScript
declare class Cache {
private _driver;
constructor();
provider(): string;
/**
* The 'driver' method is used to pick a driver for the cache
*
* @param {string} driver 'db' | 'memory' | 'redis'
* @returns {this} this
*/
driver(driver: 'db' | 'memory' | 'redis'): this;
/**
* The 'all' method is used get all cache
*
* @returns {Promise<array>} array
*/
all<T = any>(): Promise<T[] | any[]>;
/**
* The 'exists' method is used get all cache
*
* @param {string} key
* @returns {Promise<array>} array
*/
exists(key: string): Promise<boolean>;
/**
* The 'get' method is used get cache by key
* @param {string} key
* @returns {any} any
*/
get<T>(key: string): Promise<T | any>;
/**
* The 'set' method is used set the cache
*
* @param {string} key
* @param {unknown} value
* @param {number} ms
* @returns {Promise<void>} void
*/
set(key: string, value: unknown, ms: number): Promise<void>;
/**
* The 'clear' method is used clear all cache
*
* @returns {Promise<void>} void
*/
clear(): Promise<void>;
/**
* The 'clear' method is used delete cache by key
*
* @returns {Promise<void>} void
*/
delete(key: string): Promise<void>;
private _chooseDriver;
}
declare const cacheInstance: Cache;
export { cacheInstance as Cache, Cache as TCache };
export default cacheInstance;