redis-abstraction
Version:
A Redis client pool with abstraction to different Redis libraries.
34 lines (33 loc) • 1.51 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { IRedisClientPool } from "./i-redis-client-pool";
import crypto from 'node:crypto';
import fs from 'node:fs';
import Redis, { Cluster } from 'ioredis';
export declare type RedisConnection = Cluster | Redis;
export declare class IORedisClientPool implements IRedisClientPool {
private readonly nodeFSModule;
private readonly nodeCryptoModule;
private poolRedisClients;
private activeRedisClients;
private filenameToCommand;
private redisConnectionCreator;
private idlePoolSize;
private totalConnectionCounter;
constructor(redisConnectionCreator: () => RedisConnection, idlePoolSize?: number, nodeFSModule?: typeof fs, nodeCryptoModule?: typeof crypto);
generateUniqueToken(prefix: string): string;
shutdown(): Promise<void>;
acquire(token: string): Promise<void>;
release(token: string): Promise<void>;
run(token: string, commandArgs: any): Promise<unknown>;
pipeline(token: string, commands: string[][], transaction?: boolean): Promise<unknown[] | undefined>;
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[], instanceInjection?: <T>(c: new (...args: any) => T, args: any[]) => T): RedisConnection;
}