mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-17 03:24:15 +08:00
support all Redis.Cluster node types (#22500)
This commit is contained in:
committed by
Mohamed Hegazy
parent
20bad0bb87
commit
cc7f9b4e0c
10
types/ioredis/index.d.ts
vendored
10
types/ioredis/index.d.ts
vendored
@@ -4,6 +4,7 @@
|
||||
// Christopher Eck <https://github.com/chrisleck>
|
||||
// Yoga Aliarham <https://github.com/aliarham11>
|
||||
// Ebrahim <https://github.com/br8h>
|
||||
// Shahar Mor <https://github.com/shaharmor>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -744,8 +745,15 @@ declare namespace IORedis {
|
||||
pfcount(...keys: string[]): Pipeline;
|
||||
}
|
||||
|
||||
interface NodeConfiguration {
|
||||
host?: string;
|
||||
port?: number;
|
||||
}
|
||||
|
||||
type ClusterNode = string | number | NodeConfiguration;
|
||||
|
||||
interface Cluster extends NodeJS.EventEmitter, Commander {
|
||||
new(nodes: Array<{ host: string; port: number; }>, options?: ClusterOptions): Redis;
|
||||
new(nodes: ClusterNode[], options?: ClusterOptions): Redis;
|
||||
connect(callback: () => void): Promise<any>;
|
||||
disconnect(): void;
|
||||
nodes(role: string): Redis[];
|
||||
|
||||
@@ -107,3 +107,24 @@ redis.multi([
|
||||
|
||||
const keys = [ 'foo', 'bar' ];
|
||||
redis.mget(...keys);
|
||||
|
||||
new Redis.Cluster([
|
||||
'localhost'
|
||||
]);
|
||||
|
||||
new Redis.Cluster([
|
||||
6379
|
||||
]);
|
||||
|
||||
new Redis.Cluster([{
|
||||
host: 'localhost'
|
||||
}]);
|
||||
|
||||
new Redis.Cluster([{
|
||||
port: 6379
|
||||
}]);
|
||||
|
||||
new Redis.Cluster([{
|
||||
host: 'localhost',
|
||||
port: 6379
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user