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