import Redis, { type Cluster, type NodeRole } from 'ioredis'; import { AbstractConnection } from './abstract_connection.ts'; import type { ConnectionEvents, IORedisBaseCommands, RedisClusterConnectionConfig } from '../types.ts'; /** * Redis cluster connection exposes the API to run Redis commands using `ioredis` as the * underlying client. The class abstracts the need of creating and managing multiple * pub/sub connections by hand, since it handles that internally by itself. * * @example * ```ts * const cluster = new RedisClusterConnection('cluster', [ * { host: '127.0.0.1', port: 7000 }, * { host: '127.0.0.1', port: 7001 } * ], { enableOfflineQueue: false }) * * await cluster.set('key', 'value') * const value = await cluster.get('key') * ``` */ export declare class RedisClusterConnection extends AbstractConnection> { #private; /** * Returns the cluster slots configuration */ get slots(): string[][]; /** * Create a new Redis cluster connection * * @param connectionName - Unique name for this connection * @param hosts - Array of cluster node configurations * @param config - Redis cluster configuration options * * @example * ```ts * const connection = new RedisClusterConnection( * 'main-cluster', * [{ host: '127.0.0.1', port: 7000 }], * { enableOfflineQueue: false } * ) * ``` */ constructor(connectionName: string, hosts: RedisClusterConnectionConfig['clusters'], config: RedisClusterConnectionConfig['clusterOptions']); /** * Creates the subscriber connection, the AbstractConnection will * invoke this method when first subscription is created. */ protected makeSubscriberConnection(): void; /** * Returns cluster nodes * * @param role - Optional role filter ('master', 'slave', or 'all') * * @example * ```ts * // Get all nodes * const allNodes = cluster.nodes() * * // Get only master nodes * const masterNodes = cluster.nodes('master') * ``` */ nodes(role?: NodeRole): Redis.Redis[]; } export interface RedisClusterConnection extends IORedisBaseCommands { } export default RedisClusterConnection;