@nestjs-labs/nestjs-redis
Version:
Redis(node-redis) module for Nest framework (node.js).
59 lines (58 loc) • 1.79 kB
TypeScript
import type { RedisClientType, RedisClusterType, RedisFunctions, RedisModules, RedisScripts } from 'redis';
import { OnModuleDestroy } from '@nestjs/common';
/**
* The redis connection manager (single instance or cluster).
*/
export declare class RedisService<M extends RedisModules = RedisModules, F extends RedisFunctions = RedisFunctions, S extends RedisScripts = RedisScripts> implements OnModuleDestroy {
private readonly client;
constructor(client: RedisClientType<M, F, S> | RedisClusterType<M, F, S>);
/**
* Get the redis client instance.
*/
getClient(): RedisClientType<M, F, S> | RedisClusterType<M, F, S>;
/**
* Check if the client is connected.
*/
isConnected(): boolean;
/**
* Wait for the client to be ready.
*/
waitForReady(): Promise<void>;
/**
* Health check for the Redis connection.
*/
healthCheck(): Promise<{
message?: string;
status: 'up' | 'down';
}>;
/**
* Get the redis cluster client instance.
* Returns null if the client is not in cluster mode.
*/
getCluster(): RedisClusterType<M, F, S> | null;
/** *
* Get the redis cluster client instance.
* Throws an error if the client is not in cluster mode.
*/
getClusterOrThrow(): RedisClusterType<M, F, S>;
/**
* Check if the client is in cluster mode.
*/
isClusterMode(): boolean;
/**
* Get client type information.
*/
getClientType(): 'single' | 'cluster';
/**
* Get cluster information if in cluster mode.
*/
getClusterInfo(): 'single' | {
masters: number;
type: 'cluster';
nodes: string[];
};
/**
* Quit the redis client instance.
*/
onModuleDestroy(): Promise<void>;
}