You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
@@ -15,7 +15,10 @@ import { ClientClosedError, DisconnectsClientError, AuthError } from '../errors'
|
||||
import { URL } from 'url';
|
||||
import { TcpSocketConnectOpts } from 'net';
|
||||
|
||||
export interface RedisClientOptions<M extends RedisModules, S extends RedisScripts> extends RedisPlugins<M, S> {
|
||||
export interface RedisClientOptions<
|
||||
M extends RedisModules = Record<string, never>,
|
||||
S extends RedisScripts = Record<string, never>
|
||||
> extends RedisPlugins<M, S> {
|
||||
url?: string;
|
||||
socket?: RedisSocketOptions;
|
||||
username?: string;
|
||||
@@ -73,8 +76,10 @@ export type WithScripts<S extends RedisScripts> = {
|
||||
[P in keyof S as ExcludeMappedString<P>]: RedisClientCommandSignature<S[P]>;
|
||||
};
|
||||
|
||||
export type RedisClientType<M extends RedisModules, S extends RedisScripts> =
|
||||
RedisClient<M, S> & WithCommands & WithModules<M> & WithScripts<S>;
|
||||
export type RedisClientType<
|
||||
M extends RedisModules = Record<string, never>,
|
||||
S extends RedisScripts = Record<string, never>
|
||||
> = RedisClient<M, S> & WithCommands & WithModules<M> & WithScripts<S>;
|
||||
|
||||
export type InstantiableRedisClient<M extends RedisModules, S extends RedisScripts> =
|
||||
new (options?: RedisClientOptions<M, S>) => RedisClientType<M, S>;
|
||||
@@ -112,10 +117,10 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
||||
return new (RedisClient.extend(options))(options);
|
||||
}
|
||||
|
||||
static parseURL(url: string): RedisClientOptions<Record<string, never>, Record<string, never>> {
|
||||
static parseURL(url: string): RedisClientOptions {
|
||||
// https://www.iana.org/assignments/uri-schemes/prov/redis
|
||||
const { hostname, port, protocol, username, password, pathname } = new URL(url),
|
||||
parsed: RedisClientOptions<Record<string, never>, Record<string, never>> = {
|
||||
parsed: RedisClientOptions = {
|
||||
socket: {
|
||||
host: hostname
|
||||
}
|
||||
|
@@ -7,9 +7,12 @@ import { EventEmitter } from 'events';
|
||||
import RedisClusterMultiCommand, { RedisClusterMultiCommandType } from './multi-command';
|
||||
import { RedisMultiQueuedCommand } from '../multi-command';
|
||||
|
||||
export type RedisClusterClientOptions = Omit<RedisClientOptions<Record<string, never>, Record<string, never>>, 'modules' | 'scripts'>;
|
||||
export type RedisClusterClientOptions = Omit<RedisClientOptions, 'modules' | 'scripts'>;
|
||||
|
||||
export interface RedisClusterOptions<M extends RedisModules, S extends RedisScripts> extends RedisPlugins<M, S> {
|
||||
export interface RedisClusterOptions<
|
||||
M extends RedisModules = Record<string, never>,
|
||||
S extends RedisScripts = Record<string, never>
|
||||
> extends RedisPlugins<M, S> {
|
||||
rootNodes: Array<RedisClusterClientOptions>;
|
||||
defaults?: Partial<RedisClusterClientOptions>;
|
||||
useReplicas?: boolean;
|
||||
@@ -20,8 +23,10 @@ type WithCommands = {
|
||||
[P in keyof typeof COMMANDS]: RedisClientCommandSignature<(typeof COMMANDS)[P]>;
|
||||
};
|
||||
|
||||
export type RedisClusterType<M extends RedisModules, S extends RedisScripts> =
|
||||
RedisCluster<M, S> & WithCommands & WithModules<M> & WithScripts<S>;
|
||||
export type RedisClusterType<
|
||||
M extends RedisModules = Record<string, never>,
|
||||
S extends RedisScripts = Record<string, never>
|
||||
> = RedisCluster<M, S> & WithCommands & WithModules<M> & WithScripts<S>;
|
||||
|
||||
export default class RedisCluster<M extends RedisModules, S extends RedisScripts> extends EventEmitter {
|
||||
static extractFirstKey(command: RedisCommand, originalArgs: Array<unknown>, redisArgs: RedisCommandArguments): RedisCommandArgument | undefined {
|
||||
|
Reference in New Issue
Block a user