redis-abstraction
Version:
A Redis client pool with abstraction to different Redis libraries.
37 lines (36 loc) • 1.87 kB
TypeScript
import crypto from 'node:crypto';
import fs from 'node:fs';
import { IRedisClientPool } from "./i-redis-client-pool";
import { TIORedisCommonCommands } from "./t-ioredis-common-commands";
/**
* A Redis Client Pool implementation using ioredis library
* @template redisConnectionType Type of the ioredis connection (Redis or Cluster)
*/
export declare class IORedisClientPool<redisConnectionType extends TIORedisCommonCommands> implements IRedisClientPool {
private readonly nodeFSModule;
private readonly nodeCryptoModule;
private poolRedisClients;
private activeRedisClients;
private filenameToCommand;
private redisConnectionCreator;
private idlePoolSize;
private totalConnectionCounter;
constructor(redisConnectionCreator: () => redisConnectionType, idlePoolSize?: number, nodeFSModule?: typeof fs, nodeCryptoModule?: typeof crypto);
initialize(): Promise<void>;
generateUniqueToken(prefix: string): string;
shutdown(): Promise<void>;
acquire(token: string): Promise<void>;
release(token: string): Promise<void>;
run(token: string, commandArgs: any): Promise<any>;
pipeline(token: string, commands: string[][], transaction?: boolean): Promise<any[]>;
script(token: string, filePath: string, keys: string[], args: any[]): Promise<any>;
info(): {
"Idle Size": number;
"Current Active": number;
"Pooled Connection": number;
"Peak Connections": number;
};
private MD5Hash;
static IORedisClientClusterFactory(connectionDetails: string[], redisClass: new (...args: any) => TIORedisCommonCommands, clusterClass: new (...args: any) => TIORedisCommonCommands, parseURLFunction: (url: string) => Record<string, any>, instanceInjection?: <T>(c: new (...args: any) => T, args: any[]) => T): TIORedisCommonCommands;
[Symbol.asyncDispose](): Promise<void>;
}