UNPKG

@onurege3467/zerohelper

Version:

ZeroHelper is a versatile high-performance utility library and database framework for Node.js, fully written in TypeScript.

35 lines (34 loc) 1.56 kB
import { IDatabase, HookType, HookFunction } from './IDatabase'; export declare class CacheWrapper extends IDatabase { db: IDatabase; private cacheType; private tableCaches; private redisClient; private redisAvailable; private ttl; private keyPrefix; private cache; constructor(databaseInstance: IDatabase, options?: any); /** * Redirect hooks registration to the underlying database instance. */ on(hook: HookType, fn: HookFunction): void; private _initMemoryCache; private _initRedisCache; private _getCache; private _generateKey; private _getCacheValue; private _setCacheValue; private _clearCache; select<T = any>(table: string, where?: Record<string, any> | null): Promise<T[]>; selectOne<T = any>(table: string, where?: Record<string, any> | null): Promise<T | null>; insert(table: string, data: Record<string, any>): Promise<any>; update(table: string, data: Record<string, any>, where: Record<string, any>): Promise<number>; set(table: string, data: Record<string, any>, where: Record<string, any>): Promise<any>; delete(table: string, where: Record<string, any>): Promise<number>; bulkInsert(table: string, dataArray: Record<string, any>[]): Promise<number>; increment(table: string, increments: Record<string, number>, where?: Record<string, any>): Promise<number>; decrement(table: string, decrements: Record<string, number>, where?: Record<string, any>): Promise<number>; close(): Promise<void>; } export default CacheWrapper;