You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-01 16:46:54 +03:00
remove some commands from cluster, npm update, clean code,
This commit is contained in:
122
benchmark/package-lock.json
generated
122
benchmark/package-lock.json
generated
@ -7,7 +7,7 @@
|
||||
"name": "benchmark",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"benny": "^3.6.15",
|
||||
"benny": "^3.7.0",
|
||||
"v3": "npm:redis@3.1.2",
|
||||
"v4": "file:../"
|
||||
}
|
||||
@ -24,20 +24,21 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.1",
|
||||
"@tsconfig/node12": "^1.0.9",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node": "^16.9.6",
|
||||
"@types/sinon": "^10.0.3",
|
||||
"@types/node": "^16.10.3",
|
||||
"@types/sinon": "^10.0.4",
|
||||
"@types/which": "^2.0.1",
|
||||
"@types/yallist": "^4.0.1",
|
||||
"mocha": "^9.1.1",
|
||||
"mocha": "^9.1.2",
|
||||
"nyc": "^15.1.0",
|
||||
"release-it": "^14.11.6",
|
||||
"sinon": "^11.1.2",
|
||||
"source-map-support": "^0.5.20",
|
||||
"ts-node": "^10.2.1",
|
||||
"typedoc": "0.21.9",
|
||||
"typedoc-github-wiki-theme": "^0.5.1",
|
||||
"typedoc-plugin-markdown": "3.10.4",
|
||||
"ts-node": "^10.3.0",
|
||||
"typedoc": "^0.22.5",
|
||||
"typedoc-github-wiki-theme": "^0.6.0",
|
||||
"typedoc-plugin-markdown": "^3.11.3",
|
||||
"typescript": "^4.4.3",
|
||||
"which": "^2.0.2"
|
||||
},
|
||||
@ -126,14 +127,6 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/at-least-node": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
|
||||
"integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==",
|
||||
"engines": {
|
||||
"node": ">= 4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/benchmark": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz",
|
||||
@ -144,20 +137,21 @@
|
||||
}
|
||||
},
|
||||
"node_modules/benny": {
|
||||
"version": "3.6.15",
|
||||
"resolved": "https://registry.npmjs.org/benny/-/benny-3.6.15.tgz",
|
||||
"integrity": "sha512-kq6XVGGYVou3Y8KNPs3SEF881vi5fJ8sIf9w69D2rreiNfRicWVWK6u6/mObMw6BiexoHHumtipn5gcu0Tngng==",
|
||||
"version": "3.7.0",
|
||||
"resolved": "https://registry.npmjs.org/benny/-/benny-3.7.0.tgz",
|
||||
"integrity": "sha512-tfQ8s4qwjfyMvFqe7wSGGel2Pzgl5ytwztS72Xh/ynPKJeXFLQ0sSVL95X9wHpqpXqW13pTHsEMCggrNKgeAoA==",
|
||||
"dependencies": {
|
||||
"@arrows/composition": "^1.0.0",
|
||||
"@arrows/dispatch": "^1.0.2",
|
||||
"@arrows/multimethod": "^1.1.6",
|
||||
"benchmark": "^2.1.4",
|
||||
"fs-extra": "^9.0.1",
|
||||
"json2csv": "^5.0.4",
|
||||
"kleur": "^4.1.3",
|
||||
"log-update": "^4.0.0",
|
||||
"prettier": "^2.1.2",
|
||||
"stats-median": "^1.0.1"
|
||||
"fs-extra": "^10.0.0",
|
||||
"json2csv": "^5.0.6",
|
||||
"kleur": "^4.1.4",
|
||||
"log-update": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/cli-cursor": {
|
||||
@ -214,17 +208,16 @@
|
||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
|
||||
},
|
||||
"node_modules/fs-extra": {
|
||||
"version": "9.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
|
||||
"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz",
|
||||
"integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==",
|
||||
"dependencies": {
|
||||
"at-least-node": "^1.0.0",
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/graceful-fs": {
|
||||
@ -338,17 +331,6 @@
|
||||
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
|
||||
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg=="
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz",
|
||||
"integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==",
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/redis-commands": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz",
|
||||
@ -406,11 +388,6 @@
|
||||
"url": "https://github.com/chalk/slice-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/stats-median": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/stats-median/-/stats-median-1.0.1.tgz",
|
||||
"integrity": "sha512-IYsheLg6dasD3zT/w9+8Iq9tcIQqqu91ZIpJOnIEM25C3X/g4Tl8mhXwW2ZQpbrsJISr9+wizEYgsibN5/b32Q=="
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
@ -555,11 +532,6 @@
|
||||
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
|
||||
"integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ=="
|
||||
},
|
||||
"at-least-node": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
|
||||
"integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg=="
|
||||
},
|
||||
"benchmark": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz",
|
||||
@ -570,20 +542,18 @@
|
||||
}
|
||||
},
|
||||
"benny": {
|
||||
"version": "3.6.15",
|
||||
"resolved": "https://registry.npmjs.org/benny/-/benny-3.6.15.tgz",
|
||||
"integrity": "sha512-kq6XVGGYVou3Y8KNPs3SEF881vi5fJ8sIf9w69D2rreiNfRicWVWK6u6/mObMw6BiexoHHumtipn5gcu0Tngng==",
|
||||
"version": "3.7.0",
|
||||
"resolved": "https://registry.npmjs.org/benny/-/benny-3.7.0.tgz",
|
||||
"integrity": "sha512-tfQ8s4qwjfyMvFqe7wSGGel2Pzgl5ytwztS72Xh/ynPKJeXFLQ0sSVL95X9wHpqpXqW13pTHsEMCggrNKgeAoA==",
|
||||
"requires": {
|
||||
"@arrows/composition": "^1.0.0",
|
||||
"@arrows/dispatch": "^1.0.2",
|
||||
"@arrows/multimethod": "^1.1.6",
|
||||
"benchmark": "^2.1.4",
|
||||
"fs-extra": "^9.0.1",
|
||||
"json2csv": "^5.0.4",
|
||||
"kleur": "^4.1.3",
|
||||
"log-update": "^4.0.0",
|
||||
"prettier": "^2.1.2",
|
||||
"stats-median": "^1.0.1"
|
||||
"fs-extra": "^10.0.0",
|
||||
"json2csv": "^5.0.6",
|
||||
"kleur": "^4.1.4",
|
||||
"log-update": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"cli-cursor": {
|
||||
@ -628,11 +598,10 @@
|
||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "9.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
|
||||
"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz",
|
||||
"integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==",
|
||||
"requires": {
|
||||
"at-least-node": "^1.0.0",
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^2.0.0"
|
||||
@ -716,11 +685,6 @@
|
||||
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
|
||||
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg=="
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz",
|
||||
"integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA=="
|
||||
},
|
||||
"redis-commands": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz",
|
||||
@ -763,11 +727,6 @@
|
||||
"is-fullwidth-code-point": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"stats-median": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/stats-median/-/stats-median-1.0.1.tgz",
|
||||
"integrity": "sha512-IYsheLg6dasD3zT/w9+8Iq9tcIQqqu91ZIpJOnIEM25C3X/g4Tl8mhXwW2ZQpbrsJISr9+wizEYgsibN5/b32Q=="
|
||||
},
|
||||
"string-width": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
@ -811,23 +770,24 @@
|
||||
"version": "file:..",
|
||||
"requires": {
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.1",
|
||||
"@tsconfig/node12": "^1.0.9",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node": "^16.9.6",
|
||||
"@types/sinon": "^10.0.3",
|
||||
"@types/node": "^16.10.3",
|
||||
"@types/sinon": "^10.0.4",
|
||||
"@types/which": "^2.0.1",
|
||||
"@types/yallist": "^4.0.1",
|
||||
"cluster-key-slot": "1.1.0",
|
||||
"generic-pool": "3.8.2",
|
||||
"mocha": "^9.1.1",
|
||||
"mocha": "^9.1.2",
|
||||
"nyc": "^15.1.0",
|
||||
"redis-parser": "3.0.0",
|
||||
"release-it": "^14.11.6",
|
||||
"sinon": "^11.1.2",
|
||||
"source-map-support": "^0.5.20",
|
||||
"ts-node": "^10.2.1",
|
||||
"typedoc": "0.21.9",
|
||||
"typedoc-github-wiki-theme": "^0.5.1",
|
||||
"typedoc-plugin-markdown": "3.10.4",
|
||||
"ts-node": "^10.3.0",
|
||||
"typedoc": "^0.22.5",
|
||||
"typedoc-github-wiki-theme": "^0.6.0",
|
||||
"typedoc-plugin-markdown": "^3.11.3",
|
||||
"typescript": "^4.4.3",
|
||||
"which": "^2.0.2",
|
||||
"yallist": "4.0.0"
|
||||
|
@ -10,7 +10,7 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"benny": "^3.6.15",
|
||||
"benny": "^3.7.0",
|
||||
"v3": "npm:redis@3.1.2",
|
||||
"v4": "file:../"
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import LinkedList from 'yallist';
|
||||
import RedisParser from 'redis-parser';
|
||||
import { AbortError } from './errors';
|
||||
import { RedisReply } from './commands';
|
||||
import { AbortError } from '../errors';
|
||||
import { RedisCommandRawReply } from '../commands';
|
||||
|
||||
export interface QueueCommandOptions {
|
||||
asap?: boolean;
|
||||
@ -107,7 +107,7 @@ export default class RedisCommandsQueue {
|
||||
this.#maxLength = maxLength;
|
||||
}
|
||||
|
||||
addCommand<T = RedisReply>(args: Array<string | Buffer>, options?: QueueCommandOptions, bufferMode?: boolean): Promise<T> {
|
||||
addCommand<T = RedisCommandRawReply>(args: Array<string | Buffer>, options?: QueueCommandOptions, bufferMode?: boolean): Promise<T> {
|
||||
if (this.#pubSubState.subscribing || this.#pubSubState.subscribed) {
|
||||
return Promise.reject(new Error('Cannot send commands in PubSub mode'));
|
||||
} else if (this.#maxLength && this.#waitingToBeSent.length + this.#waitingForReply.length >= this.#maxLength) {
|
233
lib/client/commands.ts
Normal file
233
lib/client/commands.ts
Normal file
@ -0,0 +1,233 @@
|
||||
import CLUSTER_COMMANDS from '../cluster/commands';
|
||||
import * as ACL_CAT from '../commands/ACL_CAT';
|
||||
import * as ACL_DELUSER from '../commands/ACL_DELUSER';
|
||||
import * as ACL_GENPASS from '../commands/ACL_GENPASS';
|
||||
import * as ACL_GETUSER from '../commands/ACL_GETUSER';
|
||||
import * as ACL_LIST from '../commands/ACL_LIST';
|
||||
import * as ACL_LOAD from '../commands/ACL_LOAD';
|
||||
import * as ACL_LOG_RESET from '../commands/ACL_LOG_RESET';
|
||||
import * as ACL_LOG from '../commands/ACL_LOG';
|
||||
import * as ACL_SAVE from '../commands/ACL_SAVE';
|
||||
import * as ACL_SETUSER from '../commands/ACL_SETUSER';
|
||||
import * as ACL_USERS from '../commands/ACL_USERS';
|
||||
import * as ACL_WHOAMI from '../commands/ACL_WHOAMI';
|
||||
import * as ASKING from '../commands/ASKING';
|
||||
import * as AUTH from '../commands/AUTH';
|
||||
import * as BGREWRITEAOF from '../commands/BGREWRITEAOF';
|
||||
import * as BGSAVE from '../commands/BGSAVE';
|
||||
import * as CLIENT_ID from '../commands/CLIENT_ID';
|
||||
import * as CLIENT_INFO from '../commands/CLIENT_INFO';
|
||||
import * as CLUSTER_ADDSLOTS from '../commands/CLUSTER_ADDSLOTS';
|
||||
import * as CLUSTER_FLUSHSLOTS from '../commands/CLUSTER_FLUSHSLOTS';
|
||||
import * as CLUSTER_INFO from '../commands/CLUSTER_INFO';
|
||||
import * as CLUSTER_NODES from '../commands/CLUSTER_NODES';
|
||||
import * as CLUSTER_MEET from '../commands/CLUSTER_MEET';
|
||||
import * as CLUSTER_RESET from '../commands/CLUSTER_RESET';
|
||||
import * as CLUSTER_SETSLOT from '../commands/CLUSTER_SETSLOT';
|
||||
import * as CLUSTER_SLOTS from '../commands/CLUSTER_SLOTS';
|
||||
import * as COMMAND_COUNT from '../commands/COMMAND_COUNT';
|
||||
import * as COMMAND_GETKEYS from '../commands/COMMAND_GETKEYS';
|
||||
import * as COMMAND_INFO from '../commands/COMMAND_INFO';
|
||||
import * as COMMAND from '../commands/COMMAND';
|
||||
import * as CONFIG_GET from '../commands/CONFIG_GET';
|
||||
import * as CONFIG_RESETASTAT from '../commands/CONFIG_RESETSTAT';
|
||||
import * as CONFIG_REWRITE from '../commands/CONFIG_REWRITE';
|
||||
import * as CONFIG_SET from '../commands/CONFIG_SET';
|
||||
import * as DBSIZE from '../commands/DBSIZE';
|
||||
import * as DISCARD from '../commands/DISCARD';
|
||||
import * as ECHO from '../commands/ECHO';
|
||||
import * as FAILOVER from '../commands/FAILOVER';
|
||||
import * as FLUSHALL from '../commands/FLUSHALL';
|
||||
import * as FLUSHDB from '../commands/FLUSHDB';
|
||||
import * as HELLO from '../commands/HELLO';
|
||||
import * as INFO from '../commands/INFO';
|
||||
import * as KEYS from '../commands/KEYS';
|
||||
import * as LASTSAVE from '../commands/LASTSAVE';
|
||||
import * as LOLWUT from '../commands/LOLWUT';
|
||||
import * as MEMOERY_DOCTOR from '../commands/MEMORY_DOCTOR';
|
||||
import * as MEMORY_MALLOC_STATS from '../commands/MEMORY_MALLOC-STATS';
|
||||
import * as MEMORY_PURGE from '../commands/MEMORY_PURGE';
|
||||
import * as MEMORY_STATS from '../commands/MEMORY_STATS';
|
||||
import * as MEMORY_USAGE from '../commands/MEMORY_USAGE';
|
||||
import * as MODULE_LIST from '../commands/MODULE_LIST';
|
||||
import * as MODULE_LOAD from '../commands/MODULE_LOAD';
|
||||
import * as MODULE_UNLOAD from '../commands/MODULE_UNLOAD';
|
||||
import * as MOVE from '../commands/MOVE';
|
||||
import * as PING from '../commands/PING';
|
||||
import * as PUBSUB_CHANNELS from '../commands/PUBSUB_CHANNELS';
|
||||
import * as PUBSUB_NUMPAT from '../commands/PUBSUB_NUMPAT';
|
||||
import * as PUBSUB_NUMSUB from '../commands/PUBSUB_NUMSUB';
|
||||
import * as RANDOMKEY from '../commands/RANDOMKEY';
|
||||
import * as READONLY from '../commands/READONLY';
|
||||
import * as READWRITE from '../commands/READWRITE';
|
||||
import * as REPLICAOF from '../commands/REPLICAOF';
|
||||
import * as RESTORE_ASKING from '../commands/RESTORE-ASKING';
|
||||
import * as ROLE from '../commands/ROLE';
|
||||
import * as SAVE from '../commands/SAVE';
|
||||
import * as SCAN from '../commands/SCAN';
|
||||
import * as SCRIPT_DEBUG from '../commands/SCRIPT_DEBUG';
|
||||
import * as SCRIPT_EXISTS from '../commands/SCRIPT_EXISTS';
|
||||
import * as SCRIPT_FLUSH from '../commands/SCRIPT_FLUSH';
|
||||
import * as SCRIPT_KILL from '../commands/SCRIPT_KILL';
|
||||
import * as SCRIPT_LOAD from '../commands/SCRIPT_LOAD';
|
||||
import * as SHUTDOWN from '../commands/SHUTDOWN';
|
||||
import * as SWAPDB from '../commands/SWAPDB';
|
||||
import * as TIME from '../commands/TIME';
|
||||
import * as UNWATCH from '../commands/UNWATCH';
|
||||
import * as WAIT from '../commands/WAIT';
|
||||
|
||||
export default {
|
||||
...CLUSTER_COMMANDS,
|
||||
ACL_CAT,
|
||||
aclCat: ACL_CAT,
|
||||
ACL_DELUSER,
|
||||
aclDelUser: ACL_DELUSER,
|
||||
ACL_GENPASS,
|
||||
aclGenPass: ACL_GENPASS,
|
||||
ACL_GETUSER,
|
||||
aclGetUser: ACL_GETUSER,
|
||||
ACL_LIST,
|
||||
aclList: ACL_LIST,
|
||||
ACL_LOAD,
|
||||
aclLoad: ACL_LOAD,
|
||||
ACL_LOG_RESET,
|
||||
aclLogReset: ACL_LOG_RESET,
|
||||
ACL_LOG,
|
||||
aclLog: ACL_LOG,
|
||||
ACL_SAVE,
|
||||
aclSave: ACL_SAVE,
|
||||
ACL_SETUSER,
|
||||
aclSetUser: ACL_SETUSER,
|
||||
ACL_USERS,
|
||||
aclUsers: ACL_USERS,
|
||||
ACL_WHOAMI,
|
||||
aclWhoAmI: ACL_WHOAMI,
|
||||
ASKING,
|
||||
asking: ASKING,
|
||||
AUTH,
|
||||
auth: AUTH,
|
||||
BGREWRITEAOF,
|
||||
bgRewriteAof: BGREWRITEAOF,
|
||||
BGSAVE,
|
||||
bgSave: BGSAVE,
|
||||
CLIENT_ID,
|
||||
clientId: CLIENT_ID,
|
||||
CLIENT_INFO,
|
||||
clientInfo: CLIENT_INFO,
|
||||
CLUSTER_ADDSLOTS,
|
||||
clusterAddSlots: CLUSTER_ADDSLOTS,
|
||||
CLUSTER_FLUSHSLOTS,
|
||||
clusterFlushSlots: CLUSTER_FLUSHSLOTS,
|
||||
CLUSTER_INFO,
|
||||
clusterInfo: CLUSTER_INFO,
|
||||
CLUSTER_NODES,
|
||||
clusterNodes: CLUSTER_NODES,
|
||||
CLUSTER_MEET,
|
||||
clusterMeet: CLUSTER_MEET,
|
||||
CLUSTER_RESET,
|
||||
clusterReset: CLUSTER_RESET,
|
||||
CLUSTER_SETSLOT,
|
||||
clusterSetSlot: CLUSTER_SETSLOT,
|
||||
CLUSTER_SLOTS,
|
||||
clusterSlots: CLUSTER_SLOTS,
|
||||
COMMAND_COUNT,
|
||||
commandCount: COMMAND_COUNT,
|
||||
COMMAND_GETKEYS,
|
||||
commandGetKeys: COMMAND_GETKEYS,
|
||||
COMMAND_INFO,
|
||||
commandInfo: COMMAND_INFO,
|
||||
COMMAND,
|
||||
command: COMMAND,
|
||||
CONFIG_GET,
|
||||
configGet: CONFIG_GET,
|
||||
CONFIG_RESETASTAT,
|
||||
configResetStat: CONFIG_RESETASTAT,
|
||||
CONFIG_REWRITE,
|
||||
configRewrite: CONFIG_REWRITE,
|
||||
CONFIG_SET,
|
||||
configSet: CONFIG_SET,
|
||||
DBSIZE,
|
||||
dbSize: DBSIZE,
|
||||
DISCARD,
|
||||
discard: DISCARD,
|
||||
ECHO,
|
||||
echo: ECHO,
|
||||
FAILOVER,
|
||||
failover: FAILOVER,
|
||||
FLUSHALL,
|
||||
flushAll: FLUSHALL,
|
||||
FLUSHDB,
|
||||
flushDb: FLUSHDB,
|
||||
HELLO,
|
||||
hello: HELLO,
|
||||
INFO,
|
||||
info: INFO,
|
||||
KEYS,
|
||||
keys: KEYS,
|
||||
LASTSAVE,
|
||||
lastSave: LASTSAVE,
|
||||
LOLWUT,
|
||||
lolwut: LOLWUT,
|
||||
MEMOERY_DOCTOR,
|
||||
memoryDoctor: MEMOERY_DOCTOR,
|
||||
'MEMORY_MALLOC-STATS': MEMORY_MALLOC_STATS,
|
||||
memoryMallocStats: MEMORY_MALLOC_STATS,
|
||||
MEMORY_PURGE,
|
||||
memoryPurge: MEMORY_PURGE,
|
||||
MEMORY_STATS,
|
||||
memoryStats: MEMORY_STATS,
|
||||
MEMORY_USAGE,
|
||||
memoryUsage: MEMORY_USAGE,
|
||||
MODULE_LIST,
|
||||
moduleList: MODULE_LIST,
|
||||
MODULE_LOAD,
|
||||
moduleLoad: MODULE_LOAD,
|
||||
MODULE_UNLOAD,
|
||||
moduleUnload: MODULE_UNLOAD,
|
||||
MOVE,
|
||||
move: MOVE,
|
||||
PING,
|
||||
ping: PING,
|
||||
PUBSUB_CHANNELS,
|
||||
pubSubChannels: PUBSUB_CHANNELS,
|
||||
PUBSUB_NUMPAT,
|
||||
pubSubNumPat: PUBSUB_NUMPAT,
|
||||
PUBSUB_NUMSUB,
|
||||
pubSubNumSub: PUBSUB_NUMSUB,
|
||||
RANDOMKEY,
|
||||
randomKey: RANDOMKEY,
|
||||
READONLY,
|
||||
readonly: READONLY,
|
||||
READWRITE,
|
||||
readwrite: READWRITE,
|
||||
REPLICAOF,
|
||||
replicaOf: REPLICAOF,
|
||||
'RESTORE-ASKING': RESTORE_ASKING,
|
||||
restoreAsking: RESTORE_ASKING,
|
||||
ROLE,
|
||||
role: ROLE,
|
||||
SAVE,
|
||||
save: SAVE,
|
||||
SCAN,
|
||||
scan: SCAN,
|
||||
SCRIPT_DEBUG,
|
||||
scriptDebug: SCRIPT_DEBUG,
|
||||
SCRIPT_EXISTS,
|
||||
scriptExists: SCRIPT_EXISTS,
|
||||
SCRIPT_FLUSH,
|
||||
scriptFlush: SCRIPT_FLUSH,
|
||||
SCRIPT_KILL,
|
||||
scriptKill: SCRIPT_KILL,
|
||||
SCRIPT_LOAD,
|
||||
scriptLoad: SCRIPT_LOAD,
|
||||
SHUTDOWN,
|
||||
shutdown: SHUTDOWN,
|
||||
SWAPDB,
|
||||
swapDb: SWAPDB,
|
||||
TIME,
|
||||
time: TIME,
|
||||
UNWATCH,
|
||||
unwatch: UNWATCH,
|
||||
WAIT,
|
||||
wait: WAIT,
|
||||
};
|
@ -1,11 +1,11 @@
|
||||
import { strict as assert, AssertionError } from 'assert';
|
||||
import { once } from 'events';
|
||||
import { itWithClient, TEST_REDIS_SERVERS, TestRedisServers, waitTillBeenCalled, isRedisVersionGreaterThan } from './test-utils';
|
||||
import RedisClient from './client';
|
||||
import { AbortError, ClientClosedError, ConnectionTimeoutError, WatchError } from './errors';
|
||||
import { defineScript } from './lua-script';
|
||||
import { itWithClient, TEST_REDIS_SERVERS, TestRedisServers, waitTillBeenCalled, isRedisVersionGreaterThan } from '../test-utils';
|
||||
import RedisClient from '.';
|
||||
import { AbortError, ClientClosedError, ConnectionTimeoutError, WatchError } from '../errors';
|
||||
import { defineScript } from '../lua-script';
|
||||
import { spy } from 'sinon';
|
||||
import { RedisNetSocketOptions } from './socket';
|
||||
import { RedisNetSocketOptions } from '../client/socket';
|
||||
|
||||
export const SQUARE_SCRIPT = defineScript({
|
||||
NUMBER_OF_KEYS: 0,
|
||||
@ -366,6 +366,15 @@ describe('Client', () => {
|
||||
WatchError
|
||||
);
|
||||
});
|
||||
|
||||
itWithClient(TestRedisServers.OPEN, 'execAsPipeline', async client => {
|
||||
assert.deepEqual(
|
||||
await client.multi()
|
||||
.ping()
|
||||
.exec(true),
|
||||
['PONG']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('scripts', async () => {
|
@ -1,79 +1,81 @@
|
||||
import COMMANDS from './commands';
|
||||
import { RedisCommand, RedisCommandArguments, RedisCommandRawReply, RedisCommandReply, RedisModules, RedisPlugins, RedisScript, RedisScripts } from '../commands';
|
||||
import RedisSocket, { RedisSocketOptions, RedisNetSocketOptions, RedisTlsSocketOptions } from './socket';
|
||||
import RedisCommandsQueue, { PubSubListener, PubSubSubscribeCommands, PubSubUnsubscribeCommands, QueueCommandOptions } from './commands-queue';
|
||||
import COMMANDS, { RedisCommandReply, TransformArgumentsReply } from './commands';
|
||||
import { RedisCommand, RedisModules, RedisReply } from './commands';
|
||||
import RedisMultiCommand, { MultiQueuedCommand, RedisMultiCommandType } from './multi-command';
|
||||
import RedisClientMultiCommand, { RedisClientMultiCommandType } from './multi-command';
|
||||
import { RedisMultiQueuedCommand } from '../multi-command';
|
||||
import EventEmitter from 'events';
|
||||
import { CommandOptions, commandOptions, isCommandOptions } from './command-options';
|
||||
import { RedisLuaScript, RedisLuaScripts } from './lua-script';
|
||||
import { ScanOptions, ZMember } from './commands/generic-transformers';
|
||||
import { ScanCommandOptions } from './commands/SCAN';
|
||||
import { HScanTuple } from './commands/HSCAN';
|
||||
import { encodeCommand, extendWithDefaultCommands, extendWithModulesAndScripts, transformCommandArguments, transformCommandReply } from './commander';
|
||||
import { CommandOptions, commandOptions, isCommandOptions } from '../command-options';
|
||||
import { ScanOptions, ZMember } from '../commands/generic-transformers';
|
||||
import { ScanCommandOptions } from '../commands/SCAN';
|
||||
import { HScanTuple } from '../commands/HSCAN';
|
||||
import { encodeCommand, extendWithCommands, extendWithModulesAndScripts, transformCommandArguments, transformCommandReply } from '../commander';
|
||||
import { Pool, Options as PoolOptions, createPool } from 'generic-pool';
|
||||
import { ClientClosedError } from './errors';
|
||||
import { ClientClosedError } from '../errors';
|
||||
import { URL } from 'url';
|
||||
|
||||
export interface RedisClientOptions<M, S> {
|
||||
export interface RedisClientOptions<M extends RedisModules, S extends RedisScripts> extends RedisPlugins<M, S> {
|
||||
url?: string;
|
||||
socket?: RedisSocketOptions;
|
||||
username?: string;
|
||||
password?: string;
|
||||
database?: number;
|
||||
modules?: M;
|
||||
scripts?: S;
|
||||
commandsQueueMaxLength?: number;
|
||||
readonly?: boolean;
|
||||
legacyMode?: boolean;
|
||||
isolationPoolOptions?: PoolOptions;
|
||||
}
|
||||
|
||||
export type RedisCommandSignature<C extends RedisCommand> =
|
||||
export type RedisClientCommandSignature<C extends RedisCommand> =
|
||||
(...args: Parameters<C['transformArguments']> | [options: CommandOptions<ClientCommandOptions>, ...rest: Parameters<C['transformArguments']>]) => Promise<RedisCommandReply<C>>;
|
||||
|
||||
type WithCommands = {
|
||||
[P in keyof typeof COMMANDS]: RedisCommandSignature<(typeof COMMANDS)[P]>;
|
||||
[P in keyof typeof COMMANDS]: RedisClientCommandSignature<(typeof COMMANDS)[P]>;
|
||||
};
|
||||
|
||||
type WithModules<M extends RedisModules> = {
|
||||
export type WithModules<M extends RedisModules> = {
|
||||
[P in keyof M]: {
|
||||
[C in keyof M[P]]: RedisCommandSignature<M[P][C]>;
|
||||
[C in keyof M[P]]: RedisClientCommandSignature<M[P][C]>;
|
||||
};
|
||||
};
|
||||
|
||||
type WithScripts<S extends RedisLuaScripts> = {
|
||||
[P in keyof S]: RedisCommandSignature<S[P]>;
|
||||
export type WithScripts<S extends RedisScripts> = {
|
||||
[P in keyof S]: RedisClientCommandSignature<S[P]>;
|
||||
};
|
||||
|
||||
export type WithPlugins<M extends RedisModules, S extends RedisLuaScripts> =
|
||||
WithCommands & WithModules<M> & WithScripts<S>;
|
||||
export type RedisClientType<M extends RedisModules = {}, S extends RedisScripts = {}> =
|
||||
RedisClient<M, S> & WithCommands & WithModules<M> & WithScripts<S>;
|
||||
|
||||
export type RedisClientType<M extends RedisModules = {}, S extends RedisLuaScripts = {}> =
|
||||
WithPlugins<M, S> & RedisClient<M, S>;
|
||||
export type InstantiableRedisClient<M extends RedisModules, S extends RedisScripts> =
|
||||
new (...args: ConstructorParameters<typeof RedisClient>) => RedisClientType<M, S>;
|
||||
|
||||
export interface ClientCommandOptions extends QueueCommandOptions {
|
||||
isolated?: boolean;
|
||||
}
|
||||
|
||||
export default class RedisClient<M extends RedisModules, S extends RedisLuaScripts> extends EventEmitter {
|
||||
export default class RedisClient<M extends RedisModules, S extends RedisScripts> extends EventEmitter {
|
||||
static commandOptions(options: ClientCommandOptions): CommandOptions<ClientCommandOptions> {
|
||||
return commandOptions(options);
|
||||
}
|
||||
|
||||
static create<M extends RedisModules = {}, S extends RedisLuaScripts = {}>(options?: RedisClientOptions<M, S>): RedisClientType<M, S> {
|
||||
const Client = (<any>extendWithModulesAndScripts({
|
||||
static extend<M extends RedisModules = {}, S extends RedisScripts = {}>(plugins?: RedisPlugins<M, S>): InstantiableRedisClient<M, S> {
|
||||
const Client = <any>extendWithModulesAndScripts({
|
||||
BaseClass: RedisClient,
|
||||
modules: options?.modules,
|
||||
modules: plugins?.modules,
|
||||
modulesCommandsExecutor: RedisClient.prototype.commandsExecutor,
|
||||
scripts: options?.scripts,
|
||||
scripts: plugins?.scripts,
|
||||
scriptsExecutor: RedisClient.prototype.scriptsExecutor
|
||||
}));
|
||||
});
|
||||
|
||||
if (Client !== RedisClient) {
|
||||
Client.prototype.Multi = RedisMultiCommand.extend(options);
|
||||
Client.prototype.Multi = RedisClientMultiCommand.extend(plugins);
|
||||
}
|
||||
|
||||
return new Client(options);
|
||||
return Client;
|
||||
}
|
||||
|
||||
static create<M extends RedisModules = {}, S extends RedisScripts = {}>(options?: RedisClientOptions<M, S>): RedisClientType<M, S> {
|
||||
return new (RedisClient.extend(options))(options);
|
||||
}
|
||||
|
||||
static parseURL(url: string): RedisClientOptions<{}, {}> {
|
||||
@ -285,12 +287,12 @@ export default class RedisClient<M extends RedisModules, S extends RedisLuaScrip
|
||||
);
|
||||
}
|
||||
|
||||
sendCommand<T = RedisReply>(args: TransformArgumentsReply, options?: ClientCommandOptions, bufferMode?: boolean): Promise<T> {
|
||||
sendCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: ClientCommandOptions, bufferMode?: boolean): Promise<T> {
|
||||
return this.#sendCommand(args, options, bufferMode);
|
||||
}
|
||||
|
||||
// using `#sendCommand` cause `sendCommand` is overwritten in legacy mode
|
||||
async #sendCommand<T = RedisReply>(args: TransformArgumentsReply, options?: ClientCommandOptions, bufferMode?: boolean): Promise<T> {
|
||||
async #sendCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: ClientCommandOptions, bufferMode?: boolean): Promise<T> {
|
||||
if (!this.#socket.isOpen) {
|
||||
throw new ClientClosedError();
|
||||
}
|
||||
@ -309,7 +311,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisLuaScrip
|
||||
return await promise;
|
||||
}
|
||||
|
||||
async scriptsExecutor(script: RedisLuaScript, args: Array<unknown>): Promise<RedisCommandReply<typeof script>> {
|
||||
async scriptsExecutor(script: RedisScript, args: Array<unknown>): Promise<RedisCommandReply<typeof script>> {
|
||||
const { args: redisArgs, options } = transformCommandArguments<ClientCommandOptions>(script, args);
|
||||
|
||||
return transformCommandReply(
|
||||
@ -319,7 +321,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisLuaScrip
|
||||
);
|
||||
}
|
||||
|
||||
async executeScript(script: RedisLuaScript, args: TransformArgumentsReply, options?: ClientCommandOptions, bufferMode?: boolean): Promise<RedisCommandReply<typeof script>> {
|
||||
async executeScript(script: RedisScript, args: RedisCommandArguments, options?: ClientCommandOptions, bufferMode?: boolean): Promise<RedisCommandReply<typeof script>> {
|
||||
try {
|
||||
return await this.#sendCommand([
|
||||
'EVALSHA',
|
||||
@ -341,8 +343,6 @@ export default class RedisClient<M extends RedisModules, S extends RedisLuaScrip
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async SELECT(db: number): Promise<void>;
|
||||
async SELECT(options: CommandOptions<ClientCommandOptions>, db: number): Promise<void>;
|
||||
async SELECT(options?: any, db?: any): Promise<void> {
|
||||
@ -429,14 +429,14 @@ export default class RedisClient<M extends RedisModules, S extends RedisLuaScrip
|
||||
return this.#isolationPool.use(fn);
|
||||
}
|
||||
|
||||
multi(): RedisMultiCommandType<M, S> {
|
||||
multi(): RedisClientMultiCommandType<M, S> {
|
||||
return new (this as any).Multi(
|
||||
this.#multiExecutor.bind(this),
|
||||
this.#options
|
||||
this.multiExecutor.bind(this),
|
||||
this.#options?.legacyMode
|
||||
);
|
||||
}
|
||||
|
||||
#multiExecutor(commands: Array<MultiQueuedCommand>, chainId?: symbol): Promise<Array<RedisReply>> {
|
||||
multiExecutor(commands: Array<RedisMultiQueuedCommand>, chainId?: symbol): Promise<Array<RedisCommandRawReply>> {
|
||||
const promise = Promise.all(
|
||||
commands.map(({ args }) => {
|
||||
return this.#queue.addCommand(args, RedisClient.commandOptions({
|
||||
@ -508,5 +508,9 @@ export default class RedisClient<M extends RedisModules, S extends RedisLuaScrip
|
||||
}
|
||||
}
|
||||
|
||||
extendWithDefaultCommands(RedisClient, RedisClient.prototype.commandsExecutor);
|
||||
(RedisClient.prototype as any).Multi = RedisMultiCommand.extend();
|
||||
extendWithCommands({
|
||||
BaseClass: RedisClient,
|
||||
commands: COMMANDS,
|
||||
executor: RedisClient.prototype.commandsExecutor
|
||||
});
|
||||
(RedisClient.prototype as any).Multi = RedisClientMultiCommand;
|
132
lib/client/multi-command.ts
Normal file
132
lib/client/multi-command.ts
Normal file
@ -0,0 +1,132 @@
|
||||
import COMMANDS from './commands';
|
||||
import { RedisCommand, RedisCommandArguments, RedisCommandRawReply, RedisModules, RedisPlugins, RedisScript, RedisScripts } from '../commands';
|
||||
import RedisMultiCommand, { RedisMultiQueuedCommand } from '../multi-command';
|
||||
import { extendWithCommands, extendWithModulesAndScripts } from '../commander';
|
||||
|
||||
type RedisClientMultiCommandSignature<C extends RedisCommand, M extends RedisModules, S extends RedisScripts> =
|
||||
(...args: Parameters<C['transformArguments']>) => RedisClientMultiCommandType<M, S>;
|
||||
|
||||
type WithCommands<M extends RedisModules, S extends RedisScripts> = {
|
||||
[P in keyof typeof COMMANDS]: RedisClientMultiCommandSignature<(typeof COMMANDS)[P], M, S>
|
||||
};
|
||||
|
||||
type WithModules<M extends RedisModules, S extends RedisScripts> = {
|
||||
[P in keyof M]: {
|
||||
[C in keyof M[P]]: RedisClientMultiCommandSignature<M[P][C], M, S>;
|
||||
};
|
||||
};
|
||||
|
||||
type WithScripts<M extends RedisModules, S extends RedisScripts> = {
|
||||
[P in keyof S]: RedisClientMultiCommandSignature<S[P], M, S>
|
||||
};
|
||||
|
||||
export type RedisClientMultiCommandType<M extends RedisModules = {}, S extends RedisScripts = {}> =
|
||||
RedisClientMultiCommand & WithCommands<M, S> & WithModules<M, S> & WithScripts<M, S>;
|
||||
|
||||
export type RedisClientMultiExecutor = (queue: Array<RedisMultiQueuedCommand>, chainId?: symbol) => Promise<Array<RedisCommandRawReply>>;
|
||||
|
||||
export default class RedisClientMultiCommand {
|
||||
readonly #multi = new RedisMultiCommand();
|
||||
readonly #executor: RedisClientMultiExecutor;
|
||||
|
||||
static extend<M extends RedisModules, S extends RedisScripts>(
|
||||
plugins?: RedisPlugins<M, S>
|
||||
): new (...args: ConstructorParameters<typeof RedisMultiCommand>) => RedisClientMultiCommandType<M, S> {
|
||||
return <any>extendWithModulesAndScripts({
|
||||
BaseClass: RedisClientMultiCommand,
|
||||
modules: plugins?.modules,
|
||||
modulesCommandsExecutor: RedisClientMultiCommand.prototype.commandsExecutor,
|
||||
scripts: plugins?.scripts,
|
||||
scriptsExecutor: RedisClientMultiCommand.prototype.scriptsExecutor
|
||||
});
|
||||
}
|
||||
|
||||
readonly v4: Record<string, any> = {};
|
||||
|
||||
constructor(executor: RedisClientMultiExecutor, legacyMode = false) {
|
||||
this.#executor = executor;
|
||||
if (legacyMode) {
|
||||
this.#legacyMode();
|
||||
}
|
||||
}
|
||||
|
||||
#legacyMode(): void {
|
||||
this.v4.addCommand = this.addCommand.bind(this);
|
||||
(this as any).addCommand = (...args: Array<string | Buffer | Array<string | Buffer>>): this => {
|
||||
this.#multi.addCommand(args.flat());
|
||||
return this;
|
||||
};
|
||||
this.v4.exec = this.exec.bind(this);
|
||||
(this as any).exec = (callback?: (err: Error | null, replies?: Array<unknown>) => unknown): void => {
|
||||
this.v4.exec()
|
||||
.then((reply: Array<unknown>) => {
|
||||
if (!callback) return;
|
||||
|
||||
callback(null, reply);
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
if (!callback) {
|
||||
// this.emit('error', err);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
|
||||
for (const name of Object.keys(COMMANDS)) {
|
||||
this.#defineLegacyCommand(name);
|
||||
}
|
||||
}
|
||||
|
||||
#defineLegacyCommand(name: string): void {
|
||||
(this as any).v4[name] = (this as any)[name].bind(this.v4);
|
||||
(this as any)[name] = (...args: Array<unknown>): void => (this as any).addCommand(name, args);
|
||||
}
|
||||
|
||||
commandsExecutor(command: RedisCommand, args: Array<unknown>): this {
|
||||
return this.addCommand(
|
||||
command.transformArguments(...args),
|
||||
command.transformReply
|
||||
);
|
||||
}
|
||||
|
||||
addCommand(args: RedisCommandArguments, transformReply?: RedisCommand['transformReply']): this {
|
||||
this.#multi.addCommand(args, transformReply);
|
||||
return this;
|
||||
}
|
||||
|
||||
scriptsExecutor(script: RedisScript, args: Array<unknown>): this {
|
||||
this.#multi.addScript(script, args);
|
||||
return this;
|
||||
}
|
||||
|
||||
async exec(execAsPipeline = false): Promise<Array<RedisCommandRawReply>> {
|
||||
if (execAsPipeline) {
|
||||
return this.execAsPipeline();
|
||||
}
|
||||
|
||||
const commands = this.#multi.exec();
|
||||
if (!commands) return [];
|
||||
|
||||
return this.#multi.handleExecReplies(
|
||||
await this.#executor(commands, RedisMultiCommand.generateChainId())
|
||||
);
|
||||
}
|
||||
|
||||
EXEC = this.exec;
|
||||
|
||||
async execAsPipeline(): Promise<Array<RedisCommandRawReply>> {
|
||||
if (!this.#multi.queue.length) return [];
|
||||
|
||||
return this.#multi.transformReplies(
|
||||
await this.#executor(this.#multi.queue)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extendWithCommands({
|
||||
BaseClass: RedisClientMultiCommand,
|
||||
commands: COMMANDS,
|
||||
executor: RedisClientMultiCommand.prototype.commandsExecutor
|
||||
});
|
@ -1,8 +1,8 @@
|
||||
import EventEmitter from 'events';
|
||||
import net from 'net';
|
||||
import tls from 'tls';
|
||||
import { ConnectionTimeoutError, ClientClosedError } from './errors';
|
||||
import { promiseTimeout } from './utils';
|
||||
import { ConnectionTimeoutError, ClientClosedError } from '../errors';
|
||||
import { promiseTimeout } from '../utils';
|
||||
|
||||
export interface RedisSocketCommonOptions {
|
||||
connectTimeout?: number;
|
@ -1,16 +1,15 @@
|
||||
import calculateSlot from 'cluster-key-slot';
|
||||
import RedisClient, { RedisClientType } from './client';
|
||||
import { RedisClusterMasterNode, RedisClusterReplicaNode } from './commands/CLUSTER_NODES';
|
||||
import { RedisClusterClientOptions, RedisClusterOptions } from './cluster';
|
||||
import { RedisModules } from './commands';
|
||||
import { RedisLuaScripts } from './lua-script';
|
||||
import RedisClient, { InstantiableRedisClient, RedisClientType } from '../client';
|
||||
import { RedisClusterMasterNode, RedisClusterReplicaNode } from '../commands/CLUSTER_NODES';
|
||||
import { RedisClusterClientOptions, RedisClusterOptions } from '.';
|
||||
import { RedisModules, RedisScripts } from '../commands';
|
||||
|
||||
export interface ClusterNode<M extends RedisModules, S extends RedisLuaScripts> {
|
||||
export interface ClusterNode<M extends RedisModules, S extends RedisScripts> {
|
||||
id: string;
|
||||
client: RedisClientType<M, S>;
|
||||
}
|
||||
|
||||
interface SlotNodes<M extends RedisModules, S extends RedisLuaScripts> {
|
||||
interface SlotNodes<M extends RedisModules, S extends RedisScripts> {
|
||||
master: ClusterNode<M, S>;
|
||||
replicas: Array<ClusterNode<M, S>>;
|
||||
clientIterator: IterableIterator<RedisClientType<M, S>> | undefined;
|
||||
@ -18,14 +17,16 @@ interface SlotNodes<M extends RedisModules, S extends RedisLuaScripts> {
|
||||
|
||||
type OnError = (err: unknown) => void;
|
||||
|
||||
export default class RedisClusterSlots<M extends RedisModules, S extends RedisLuaScripts> {
|
||||
readonly #options: RedisClusterOptions;
|
||||
export default class RedisClusterSlots<M extends RedisModules, S extends RedisScripts> {
|
||||
readonly #options: RedisClusterOptions<M, S>;
|
||||
readonly #Client: InstantiableRedisClient<M, S>;
|
||||
readonly #onError: OnError;
|
||||
readonly #nodeByUrl = new Map<string, ClusterNode<M, S>>();
|
||||
readonly #slots: Array<SlotNodes<M, S>> = [];
|
||||
|
||||
constructor(options: RedisClusterOptions, onError: OnError) {
|
||||
constructor(options: RedisClusterOptions<M, S>, onError: OnError) {
|
||||
this.#options = options;
|
||||
this.#Client = RedisClient.extend(options);
|
||||
this.#onError = onError;
|
||||
}
|
||||
|
||||
@ -50,7 +51,7 @@ export default class RedisClusterSlots<M extends RedisModules, S extends RedisLu
|
||||
}
|
||||
|
||||
async #discoverNodes(clientOptions?: RedisClusterClientOptions): Promise<boolean> {
|
||||
const client = RedisClient.create(clientOptions);
|
||||
const client = new this.#Client(clientOptions);
|
||||
|
||||
await client.connect();
|
||||
|
||||
@ -118,7 +119,7 @@ export default class RedisClusterSlots<M extends RedisModules, S extends RedisLu
|
||||
if (!node) {
|
||||
node = {
|
||||
id: nodeData.id,
|
||||
client: RedisClient.create(
|
||||
client: new this.#Client(
|
||||
this.#clientOptionsDefaults({
|
||||
socket: {
|
||||
host: nodeData.host,
|
535
lib/cluster/commands.ts
Normal file
535
lib/cluster/commands.ts
Normal file
@ -0,0 +1,535 @@
|
||||
|
||||
import * as APPEND from '../commands/APPEND';
|
||||
import * as BITCOUNT from '../commands/BITCOUNT';
|
||||
import * as BITFIELD from '../commands/BITFIELD';
|
||||
import * as BITOP from '../commands/BITOP';
|
||||
import * as BITPOS from '../commands/BITPOS';
|
||||
import * as BLMOVE from '../commands/BLMOVE';
|
||||
import * as BLPOP from '../commands/BLPOP';
|
||||
import * as BRPOP from '../commands/BRPOP';
|
||||
import * as BRPOPLPUSH from '../commands/BRPOPLPUSH';
|
||||
import * as BZPOPMAX from '../commands/BZPOPMAX';
|
||||
import * as BZPOPMIN from '../commands/BZPOPMIN';
|
||||
import * as COPY from '../commands/COPY';
|
||||
import * as DECR from '../commands/DECR';
|
||||
import * as DECRBY from '../commands/DECRBY';
|
||||
import * as DEL from '../commands/DEL';
|
||||
import * as DUMP from '../commands/DUMP';
|
||||
import * as EVAL from '../commands/EVAL';
|
||||
import * as EVALSHA from '../commands/EVALSHA';
|
||||
import * as EXISTS from '../commands/EXISTS';
|
||||
import * as EXPIRE from '../commands/EXPIRE';
|
||||
import * as EXPIREAT from '../commands/EXPIREAT';
|
||||
import * as GEOADD from '../commands/GEOADD';
|
||||
import * as GEODIST from '../commands/GEODIST';
|
||||
import * as GEOHASH from '../commands/GEOHASH';
|
||||
import * as GEOPOS from '../commands/GEOPOS';
|
||||
import * as GEOSEARCH_WITH from '../commands/GEOSEARCH_WITH';
|
||||
import * as GEOSEARCH from '../commands/GEOSEARCH';
|
||||
import * as GEOSEARCHSTORE from '../commands/GEOSEARCHSTORE';
|
||||
import * as GET_BUFFER from '../commands/GET_BUFFER';
|
||||
import * as GET from '../commands/GET';
|
||||
import * as GETBIT from '../commands/GETBIT';
|
||||
import * as GETDEL from '../commands/GETDEL';
|
||||
import * as GETEX from '../commands/GETEX';
|
||||
import * as GETRANGE from '../commands/GETRANGE';
|
||||
import * as GETSET from '../commands/GETSET';
|
||||
import * as HDEL from '../commands/HDEL';
|
||||
import * as HEXISTS from '../commands/HEXISTS';
|
||||
import * as HGET from '../commands/HGET';
|
||||
import * as HGETALL from '../commands/HGETALL';
|
||||
import * as HINCRBY from '../commands/HINCRBY';
|
||||
import * as HINCRBYFLOAT from '../commands/HINCRBYFLOAT';
|
||||
import * as HKEYS from '../commands/HKEYS';
|
||||
import * as HLEN from '../commands/HLEN';
|
||||
import * as HMGET from '../commands/HMGET';
|
||||
import * as HRANDFIELD_COUNT_WITHVALUES from '../commands/HRANDFIELD_COUNT_WITHVALUES';
|
||||
import * as HRANDFIELD_COUNT from '../commands/HRANDFIELD_COUNT';
|
||||
import * as HRANDFIELD from '../commands/HRANDFIELD';
|
||||
import * as HSCAN from '../commands/HSCAN';
|
||||
import * as HSET from '../commands/HSET';
|
||||
import * as HSETNX from '../commands/HSETNX';
|
||||
import * as HSTRLEN from '../commands/HSTRLEN';
|
||||
import * as HVALS from '../commands/HVALS';
|
||||
import * as INCR from '../commands/INCR';
|
||||
import * as INCRBY from '../commands/INCRBY';
|
||||
import * as INCRBYFLOAT from '../commands/INCRBYFLOAT';
|
||||
import * as LINDEX from '../commands/LINDEX';
|
||||
import * as LINSERT from '../commands/LINSERT';
|
||||
import * as LLEN from '../commands/LLEN';
|
||||
import * as LMOVE from '../commands/LMOVE';
|
||||
import * as LPOP_COUNT from '../commands/LPOP_COUNT';
|
||||
import * as LPOP from '../commands/LPOP';
|
||||
import * as LPOS_COUNT from '../commands/LPOS_COUNT';
|
||||
import * as LPOS from '../commands/LPOS';
|
||||
import * as LPUSH from '../commands/LPUSH';
|
||||
import * as LPUSHX from '../commands/LPUSHX';
|
||||
import * as LRANGE from '../commands/LRANGE';
|
||||
import * as LREM from '../commands/LREM';
|
||||
import * as LSET from '../commands/LSET';
|
||||
import * as LTRIM from '../commands/LTRIM';
|
||||
import * as MGET from '../commands/MGET';
|
||||
import * as MIGRATE from '../commands/MIGRATE';
|
||||
import * as MSET from '../commands/MSET';
|
||||
import * as MSETNX from '../commands/MSETNX';
|
||||
import * as PERSIST from '../commands/PERSIST';
|
||||
import * as PEXPIRE from '../commands/PEXPIRE';
|
||||
import * as PEXPIREAT from '../commands/PEXPIREAT';
|
||||
import * as PFADD from '../commands/PFADD';
|
||||
import * as PFCOUNT from '../commands/PFCOUNT';
|
||||
import * as PFMERGE from '../commands/PFMERGE';
|
||||
import * as PSETEX from '../commands/PSETEX';
|
||||
import * as PTTL from '../commands/PTTL';
|
||||
import * as PUBLISH from '../commands/PUBLISH';
|
||||
import * as RENAME from '../commands/RENAME';
|
||||
import * as RENAMENX from '../commands/RENAMENX';
|
||||
import * as RPOP_COUNT from '../commands/RPOP_COUNT';
|
||||
import * as RPOP from '../commands/RPOP';
|
||||
import * as RPOPLPUSH from '../commands/RPOPLPUSH';
|
||||
import * as RPUSH from '../commands/RPUSH';
|
||||
import * as RPUSHX from '../commands/RPUSHX';
|
||||
import * as SADD from '../commands/SADD';
|
||||
import * as SCARD from '../commands/SCARD';
|
||||
import * as SDIFF from '../commands/SDIFF';
|
||||
import * as SDIFFSTORE from '../commands/SDIFFSTORE';
|
||||
import * as SET from '../commands/SET';
|
||||
import * as SETBIT from '../commands/SETBIT';
|
||||
import * as SETEX from '../commands/SETEX';
|
||||
import * as SETNX from '../commands/SETNX';
|
||||
import * as SETRANGE from '../commands/SETRANGE';
|
||||
import * as SINTER from '../commands/SINTER';
|
||||
import * as SINTERSTORE from '../commands/SINTERSTORE';
|
||||
import * as SISMEMBER from '../commands/SISMEMBER';
|
||||
import * as SMEMBERS from '../commands/SMEMBERS';
|
||||
import * as SMISMEMBER from '../commands/SMISMEMBER';
|
||||
import * as SMOVE from '../commands/SMOVE';
|
||||
import * as SORT from '../commands/SORT';
|
||||
import * as SPOP from '../commands/SPOP';
|
||||
import * as SRANDMEMBER_COUNT from '../commands/SRANDMEMBER_COUNT';
|
||||
import * as SRANDMEMBER from '../commands/SRANDMEMBER';
|
||||
import * as SREM from '../commands/SREM';
|
||||
import * as SSCAN from '../commands/SSCAN';
|
||||
import * as STRLEN from '../commands/STRLEN';
|
||||
import * as SUNION from '../commands/SUNION';
|
||||
import * as SUNIONSTORE from '../commands/SUNIONSTORE';
|
||||
import * as TOUCH from '../commands/TOUCH';
|
||||
import * as TTL from '../commands/TTL';
|
||||
import * as TYPE from '../commands/TYPE';
|
||||
import * as UNLINK from '../commands/UNLINK';
|
||||
import * as WATCH from '../commands/WATCH';
|
||||
import * as XACK from '../commands/XACK';
|
||||
import * as XADD from '../commands/XADD';
|
||||
import * as XAUTOCLAIM_JUSTID from '../commands/XAUTOCLAIM_JUSTID';
|
||||
import * as XAUTOCLAIM from '../commands/XAUTOCLAIM';
|
||||
import * as XCLAIM from '../commands/XCLAIM';
|
||||
import * as XCLAIM_JUSTID from '../commands/XCLAIM_JUSTID';
|
||||
import * as XDEL from '../commands/XDEL';
|
||||
import * as XGROUP_CREATE from '../commands/XGROUP_CREATE';
|
||||
import * as XGROUP_CREATECONSUMER from '../commands/XGROUP_CREATECONSUMER';
|
||||
import * as XGROUP_DELCONSUMER from '../commands/XGROUP_DELCONSUMER';
|
||||
import * as XGROUP_DESTROY from '../commands/XGROUP_DESTROY';
|
||||
import * as XGROUP_SETID from '../commands/XGROUP_SETID';
|
||||
import * as XINFO_CONSUMERS from '../commands/XINFO_CONSUMERS';
|
||||
import * as XINFO_GROUPS from '../commands/XINFO_GROUPS';
|
||||
import * as XINFO_STREAM from '../commands/XINFO_STREAM';
|
||||
import * as XLEN from '../commands/XLEN';
|
||||
import * as XPENDING_RANGE from '../commands/XPENDING_RANGE';
|
||||
import * as XPENDING from '../commands/XPENDING';
|
||||
import * as XRANGE from '../commands/XRANGE';
|
||||
import * as XREAD from '../commands/XREAD';
|
||||
import * as XREADGROUP from '../commands/XREADGROUP';
|
||||
import * as XREVRANGE from '../commands/XREVRANGE';
|
||||
import * as XTRIM from '../commands/XTRIM';
|
||||
import * as ZADD from '../commands/ZADD';
|
||||
import * as ZCARD from '../commands/ZCARD';
|
||||
import * as ZCOUNT from '../commands/ZCOUNT';
|
||||
import * as ZDIFF_WITHSCORES from '../commands/ZDIFF_WITHSCORES';
|
||||
import * as ZDIFF from '../commands/ZDIFF';
|
||||
import * as ZDIFFSTORE from '../commands/ZDIFFSTORE';
|
||||
import * as ZINCRBY from '../commands/ZINCRBY';
|
||||
import * as ZINTER_WITHSCORES from '../commands/ZINTER_WITHSCORES';
|
||||
import * as ZINTER from '../commands/ZINTER';
|
||||
import * as ZINTERSTORE from '../commands/ZINTERSTORE';
|
||||
import * as ZLEXCOUNT from '../commands/ZLEXCOUNT';
|
||||
import * as ZMSCORE from '../commands/ZMSCORE';
|
||||
import * as ZPOPMAX_COUNT from '../commands/ZPOPMAX_COUNT';
|
||||
import * as ZPOPMAX from '../commands/ZPOPMAX';
|
||||
import * as ZPOPMIN_COUNT from '../commands/ZPOPMIN_COUNT';
|
||||
import * as ZPOPMIN from '../commands/ZPOPMIN';
|
||||
import * as ZRANDMEMBER_COUNT_WITHSCORES from '../commands/ZRANDMEMBER_COUNT_WITHSCORES';
|
||||
import * as ZRANDMEMBER_COUNT from '../commands/ZRANDMEMBER_COUNT';
|
||||
import * as ZRANDMEMBER from '../commands/ZRANDMEMBER';
|
||||
import * as ZRANGE_WITHSCORES from '../commands/ZRANGE_WITHSCORES';
|
||||
import * as ZRANGE from '../commands/ZRANGE';
|
||||
import * as ZRANGEBYLEX from '../commands/ZRANGEBYLEX';
|
||||
import * as ZRANGEBYSCORE_WITHSCORES from '../commands/ZRANGEBYSCORE_WITHSCORES';
|
||||
import * as ZRANGEBYSCORE from '../commands/ZRANGEBYSCORE';
|
||||
import * as ZRANGESTORE from '../commands/ZRANGESTORE';
|
||||
import * as ZRANK from '../commands/ZRANK';
|
||||
import * as ZREM from '../commands/ZREM';
|
||||
import * as ZREMRANGEBYLEX from '../commands/ZREMRANGEBYLEX';
|
||||
import * as ZREMRANGEBYRANK from '../commands/ZREMRANGEBYRANK';
|
||||
import * as ZREMRANGEBYSCORE from '../commands/ZREMRANGEBYSCORE';
|
||||
import * as ZREVRANK from '../commands/ZREVRANK';
|
||||
import * as ZSCAN from '../commands/ZSCAN';
|
||||
import * as ZSCORE from '../commands/ZSCORE';
|
||||
import * as ZUNION_WITHSCORES from '../commands/ZUNION_WITHSCORES';
|
||||
import * as ZUNION from '../commands/ZUNION';
|
||||
import * as ZUNIONSTORE from '../commands/ZUNIONSTORE';
|
||||
|
||||
export default {
|
||||
APPEND,
|
||||
append: APPEND,
|
||||
BITCOUNT,
|
||||
bitCount: BITCOUNT,
|
||||
BITFIELD,
|
||||
bitField: BITFIELD,
|
||||
BITOP,
|
||||
bitOp: BITOP,
|
||||
BITPOS,
|
||||
bitPos: BITPOS,
|
||||
BLMOVE,
|
||||
blMove: BLMOVE,
|
||||
BLPOP,
|
||||
blPop: BLPOP,
|
||||
BRPOP,
|
||||
brPop: BRPOP,
|
||||
BRPOPLPUSH,
|
||||
brPopLPush: BRPOPLPUSH,
|
||||
BZPOPMAX,
|
||||
bzPopMax: BZPOPMAX,
|
||||
BZPOPMIN,
|
||||
bzPopMin: BZPOPMIN,
|
||||
COPY,
|
||||
copy: COPY,
|
||||
DECR,
|
||||
decr: DECR,
|
||||
DECRBY,
|
||||
decrBy: DECRBY,
|
||||
DEL,
|
||||
del: DEL,
|
||||
DUMP,
|
||||
dump: DUMP,
|
||||
EVAL,
|
||||
eval: EVAL,
|
||||
EVALSHA,
|
||||
evalSha: EVALSHA,
|
||||
EXISTS,
|
||||
exists: EXISTS,
|
||||
EXPIRE,
|
||||
expire: EXPIRE,
|
||||
EXPIREAT,
|
||||
expireAt: EXPIREAT,
|
||||
GEOADD,
|
||||
geoAdd: GEOADD,
|
||||
GEODIST,
|
||||
geoDist: GEODIST,
|
||||
GEOHASH,
|
||||
geoHash: GEOHASH,
|
||||
GEOPOS,
|
||||
geoPos: GEOPOS,
|
||||
GEOSEARCH_WITH,
|
||||
geoSearchWith: GEOSEARCH_WITH,
|
||||
GEOSEARCH,
|
||||
geoSearch: GEOSEARCH,
|
||||
GEOSEARCHSTORE,
|
||||
geoSearchStore: GEOSEARCHSTORE,
|
||||
GET_BUFFER,
|
||||
getBuffer: GET_BUFFER,
|
||||
GET,
|
||||
get: GET,
|
||||
GETBIT,
|
||||
getBit: GETBIT,
|
||||
GETDEL,
|
||||
getDel: GETDEL,
|
||||
GETEX,
|
||||
getEx: GETEX,
|
||||
GETRANGE,
|
||||
getRange: GETRANGE,
|
||||
GETSET,
|
||||
getSet: GETSET,
|
||||
HDEL,
|
||||
hDel: HDEL,
|
||||
HEXISTS,
|
||||
hExists: HEXISTS,
|
||||
HGET,
|
||||
hGet: HGET,
|
||||
HGETALL,
|
||||
hGetAll: HGETALL,
|
||||
HINCRBY,
|
||||
hIncrBy: HINCRBY,
|
||||
HINCRBYFLOAT,
|
||||
hIncrByFloat: HINCRBYFLOAT,
|
||||
HKEYS,
|
||||
hKeys: HKEYS,
|
||||
HLEN,
|
||||
hLen: HLEN,
|
||||
HMGET,
|
||||
hmGet: HMGET,
|
||||
HRANDFIELD_COUNT_WITHVALUES,
|
||||
hRandFieldCountWithValues: HRANDFIELD_COUNT_WITHVALUES,
|
||||
HRANDFIELD_COUNT,
|
||||
hRandFieldCount: HRANDFIELD_COUNT,
|
||||
HRANDFIELD,
|
||||
hRandField: HRANDFIELD,
|
||||
HSCAN,
|
||||
hScan: HSCAN,
|
||||
HSET,
|
||||
hSet: HSET,
|
||||
HSETNX,
|
||||
hSetNX: HSETNX,
|
||||
HSTRLEN,
|
||||
hStrLen: HSTRLEN,
|
||||
HVALS,
|
||||
hVals: HVALS,
|
||||
INCR,
|
||||
incr: INCR,
|
||||
INCRBY,
|
||||
incrBy: INCRBY,
|
||||
INCRBYFLOAT,
|
||||
incrByFloat: INCRBYFLOAT,
|
||||
LINDEX,
|
||||
lIndex: LINDEX,
|
||||
LINSERT,
|
||||
lInsert: LINSERT,
|
||||
LLEN,
|
||||
lLen: LLEN,
|
||||
LMOVE,
|
||||
lMove: LMOVE,
|
||||
LPOP_COUNT,
|
||||
lPopCount: LPOP_COUNT,
|
||||
LPOP,
|
||||
lPop: LPOP,
|
||||
LPOS_COUNT,
|
||||
lPosCount: LPOS_COUNT,
|
||||
LPOS,
|
||||
lPos: LPOS,
|
||||
LPUSH,
|
||||
lPush: LPUSH,
|
||||
LPUSHX,
|
||||
lPushX: LPUSHX,
|
||||
LRANGE,
|
||||
lRange: LRANGE,
|
||||
LREM,
|
||||
lRem: LREM,
|
||||
LSET,
|
||||
lSet: LSET,
|
||||
LTRIM,
|
||||
lTrim: LTRIM,
|
||||
MGET,
|
||||
mGet: MGET,
|
||||
MIGRATE,
|
||||
migrate: MIGRATE,
|
||||
MSET,
|
||||
mSet: MSET,
|
||||
MSETNX,
|
||||
mSetNX: MSETNX,
|
||||
PERSIST,
|
||||
persist: PERSIST,
|
||||
PEXPIRE,
|
||||
pExpire: PEXPIRE,
|
||||
PEXPIREAT,
|
||||
pExpireAt: PEXPIREAT,
|
||||
PFADD,
|
||||
pfAdd: PFADD,
|
||||
PFCOUNT,
|
||||
pfCount: PFCOUNT,
|
||||
PFMERGE,
|
||||
pfMerge: PFMERGE,
|
||||
PSETEX,
|
||||
pSetEx: PSETEX,
|
||||
PTTL,
|
||||
pTTL: PTTL,
|
||||
PUBLISH,
|
||||
publish: PUBLISH,
|
||||
RENAME,
|
||||
rename: RENAME,
|
||||
RENAMENX,
|
||||
renameNX: RENAMENX,
|
||||
RPOP_COUNT,
|
||||
rPopCount: RPOP_COUNT,
|
||||
RPOP,
|
||||
rPop: RPOP,
|
||||
RPOPLPUSH,
|
||||
rPopLPush: RPOPLPUSH,
|
||||
RPUSH,
|
||||
rPush: RPUSH,
|
||||
RPUSHX,
|
||||
rPushX: RPUSHX,
|
||||
SADD,
|
||||
sAdd: SADD,
|
||||
SCARD,
|
||||
sCard: SCARD,
|
||||
SDIFF,
|
||||
sDiff: SDIFF,
|
||||
SDIFFSTORE,
|
||||
sDiffStore: SDIFFSTORE,
|
||||
SINTER,
|
||||
sInter: SINTER,
|
||||
SINTERSTORE,
|
||||
sInterStore: SINTERSTORE,
|
||||
SET,
|
||||
set: SET,
|
||||
SETBIT,
|
||||
setBit: SETBIT,
|
||||
SETEX,
|
||||
setEx: SETEX,
|
||||
SETNX,
|
||||
setNX: SETNX,
|
||||
SETRANGE,
|
||||
setRange: SETRANGE,
|
||||
SISMEMBER,
|
||||
sIsMember: SISMEMBER,
|
||||
SMEMBERS,
|
||||
sMembers: SMEMBERS,
|
||||
SMISMEMBER,
|
||||
smIsMember: SMISMEMBER,
|
||||
SMOVE,
|
||||
sMove: SMOVE,
|
||||
SORT,
|
||||
sort: SORT,
|
||||
SPOP,
|
||||
sPop: SPOP,
|
||||
SRANDMEMBER_COUNT,
|
||||
sRandMemberCount: SRANDMEMBER_COUNT,
|
||||
SRANDMEMBER,
|
||||
sRandMember: SRANDMEMBER,
|
||||
SREM,
|
||||
sRem: SREM,
|
||||
SSCAN,
|
||||
sScan: SSCAN,
|
||||
STRLEN,
|
||||
strLen: STRLEN,
|
||||
SUNION,
|
||||
sUnion: SUNION,
|
||||
SUNIONSTORE,
|
||||
sUnionStore: SUNIONSTORE,
|
||||
TOUCH,
|
||||
touch: TOUCH,
|
||||
TTL,
|
||||
ttl: TTL,
|
||||
TYPE,
|
||||
type: TYPE,
|
||||
UNLINK,
|
||||
unlink: UNLINK,
|
||||
WATCH,
|
||||
watch: WATCH,
|
||||
XACK,
|
||||
xAck: XACK,
|
||||
XADD,
|
||||
xAdd: XADD,
|
||||
XAUTOCLAIM_JUSTID,
|
||||
xAutoClaimJustId: XAUTOCLAIM_JUSTID,
|
||||
XAUTOCLAIM,
|
||||
xAutoClaim: XAUTOCLAIM,
|
||||
XCLAIM,
|
||||
xClaim: XCLAIM,
|
||||
XCLAIM_JUSTID,
|
||||
xClaimJustId: XCLAIM_JUSTID,
|
||||
XDEL,
|
||||
xDel: XDEL,
|
||||
XGROUP_CREATE,
|
||||
xGroupCreate: XGROUP_CREATE,
|
||||
XGROUP_CREATECONSUMER,
|
||||
xGroupCreateConsumer: XGROUP_CREATECONSUMER,
|
||||
XGROUP_DELCONSUMER,
|
||||
xGroupDelConsumer: XGROUP_DELCONSUMER,
|
||||
XGROUP_DESTROY,
|
||||
xGroupDestroy: XGROUP_DESTROY,
|
||||
XGROUP_SETID,
|
||||
xGroupSetId: XGROUP_SETID,
|
||||
XINFO_CONSUMERS,
|
||||
xInfoConsumers: XINFO_CONSUMERS,
|
||||
XINFO_GROUPS,
|
||||
xInfoGroups: XINFO_GROUPS,
|
||||
XINFO_STREAM,
|
||||
xInfoStream: XINFO_STREAM,
|
||||
XLEN,
|
||||
xLen: XLEN,
|
||||
XPENDING_RANGE,
|
||||
xPendingRange: XPENDING_RANGE,
|
||||
XPENDING,
|
||||
xPending: XPENDING,
|
||||
XRANGE,
|
||||
xRange: XRANGE,
|
||||
XREAD,
|
||||
xRead: XREAD,
|
||||
XREADGROUP,
|
||||
xReadGroup: XREADGROUP,
|
||||
XREVRANGE,
|
||||
xRevRange: XREVRANGE,
|
||||
XTRIM,
|
||||
xTrim: XTRIM,
|
||||
ZADD,
|
||||
zAdd: ZADD,
|
||||
ZCARD,
|
||||
zCard: ZCARD,
|
||||
ZCOUNT,
|
||||
zCount: ZCOUNT,
|
||||
ZDIFF_WITHSCORES,
|
||||
zDiffWithScores: ZDIFF_WITHSCORES,
|
||||
ZDIFF,
|
||||
zDiff: ZDIFF,
|
||||
ZDIFFSTORE,
|
||||
zDiffStore: ZDIFFSTORE,
|
||||
ZINCRBY,
|
||||
zIncrBy: ZINCRBY,
|
||||
ZINTER_WITHSCORES,
|
||||
zInterWithScores: ZINTER_WITHSCORES,
|
||||
ZINTER,
|
||||
zInter: ZINTER,
|
||||
ZINTERSTORE,
|
||||
zInterStore: ZINTERSTORE,
|
||||
ZLEXCOUNT,
|
||||
zLexCount: ZLEXCOUNT,
|
||||
ZMSCORE,
|
||||
zmScore: ZMSCORE,
|
||||
ZPOPMAX_COUNT,
|
||||
zPopMaxCount: ZPOPMAX_COUNT,
|
||||
ZPOPMAX,
|
||||
zPopMax: ZPOPMAX,
|
||||
ZPOPMIN_COUNT,
|
||||
zPopMinCount: ZPOPMIN_COUNT,
|
||||
ZPOPMIN,
|
||||
zPopMin: ZPOPMIN,
|
||||
ZRANDMEMBER_COUNT_WITHSCORES,
|
||||
zRandMemberCountWithScores: ZRANDMEMBER_COUNT_WITHSCORES,
|
||||
ZRANDMEMBER_COUNT,
|
||||
zRandMemberCount: ZRANDMEMBER_COUNT,
|
||||
ZRANDMEMBER,
|
||||
zRandMember: ZRANDMEMBER,
|
||||
ZRANGE_WITHSCORES,
|
||||
zRangeWithScores: ZRANGE_WITHSCORES,
|
||||
ZRANGE,
|
||||
zRange: ZRANGE,
|
||||
ZRANGEBYLEX,
|
||||
zRangeByLex: ZRANGEBYLEX,
|
||||
ZRANGEBYSCORE_WITHSCORES,
|
||||
zRangeByScoreWithScores: ZRANGEBYSCORE_WITHSCORES,
|
||||
ZRANGEBYSCORE,
|
||||
zRangeByScore: ZRANGEBYSCORE,
|
||||
ZRANGESTORE,
|
||||
zRangeStore: ZRANGESTORE,
|
||||
ZRANK,
|
||||
zRank: ZRANK,
|
||||
ZREM,
|
||||
zRem: ZREM,
|
||||
ZREMRANGEBYLEX,
|
||||
zRemRangeByLex: ZREMRANGEBYLEX,
|
||||
ZREMRANGEBYRANK,
|
||||
zRemRangeByRank: ZREMRANGEBYRANK,
|
||||
ZREMRANGEBYSCORE,
|
||||
zRemRangeByScore: ZREMRANGEBYSCORE,
|
||||
ZREVRANK,
|
||||
zRevRank: ZREVRANK,
|
||||
ZSCAN,
|
||||
zScan: ZSCAN,
|
||||
ZSCORE,
|
||||
zScore: ZSCORE,
|
||||
ZUNION_WITHSCORES,
|
||||
zUnionWithScores: ZUNION_WITHSCORES,
|
||||
ZUNION,
|
||||
zUnion: ZUNION,
|
||||
ZUNIONSTORE,
|
||||
zUnionStore: ZUNIONSTORE
|
||||
};
|
@ -1,9 +1,9 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import RedisCluster from './cluster';
|
||||
import { defineScript } from './lua-script';
|
||||
import { itWithCluster, itWithDedicatedCluster, TestRedisClusters, TEST_REDIS_CLUSTERES } from './test-utils';
|
||||
import RedisCluster from '.';
|
||||
import { defineScript } from '../lua-script';
|
||||
import { itWithCluster, itWithDedicatedCluster, TestRedisClusters, TEST_REDIS_CLUSTERES } from '../test-utils';
|
||||
import calculateSlot from 'cluster-key-slot';
|
||||
import { ClusterSlotStates } from './commands/CLUSTER_SETSLOT';
|
||||
import { ClusterSlotStates } from '../commands/CLUSTER_SETSLOT';
|
||||
|
||||
describe('Cluster', () => {
|
||||
it('sendCommand', async () => {
|
||||
@ -15,7 +15,7 @@ describe('Cluster', () => {
|
||||
await cluster.connect();
|
||||
|
||||
try {
|
||||
await cluster.ping();
|
||||
await cluster.publish('channel', 'message');
|
||||
await cluster.set('a', 'b');
|
||||
await cluster.set('a{a}', 'bb');
|
||||
await cluster.set('aa', 'bb');
|
||||
@ -32,11 +32,10 @@ describe('Cluster', () => {
|
||||
const key = 'key';
|
||||
assert.deepEqual(
|
||||
await cluster.multi(key)
|
||||
.ping()
|
||||
.set(key, 'value')
|
||||
.get(key)
|
||||
.exec(),
|
||||
['PONG', 'OK', 'value']
|
||||
['OK', 'value']
|
||||
);
|
||||
});
|
||||
|
@ -1,27 +1,35 @@
|
||||
import { RedisCommand, RedisCommandReply, RedisModules, TransformArgumentsReply } from './commands';
|
||||
import RedisClient, { ClientCommandOptions, RedisClientOptions, RedisClientType, WithPlugins } from './client';
|
||||
import COMMANDS from './commands';
|
||||
import { RedisCommand, RedisCommandArguments, RedisCommandReply, RedisModules, RedisScript, RedisScripts } from '../commands';
|
||||
import { ClientCommandOptions, RedisClientCommandSignature, RedisClientOptions, RedisClientType, WithModules, WithScripts } from '../client';
|
||||
import RedisClusterSlots, { ClusterNode } from './cluster-slots';
|
||||
import { RedisLuaScript, RedisLuaScripts } from './lua-script';
|
||||
import { extendWithModulesAndScripts, extendWithDefaultCommands, transformCommandArguments, transformCommandReply } from './commander';
|
||||
import RedisMultiCommand, { MultiQueuedCommand, RedisMultiCommandType } from './multi-command';
|
||||
import { extendWithModulesAndScripts, transformCommandArguments, transformCommandReply, extendWithCommands } from '../commander';
|
||||
import { EventEmitter } from 'events';
|
||||
import RedisClusterMultiCommand, { RedisClusterMultiCommandType } from './multi-command';
|
||||
import { RedisMultiQueuedCommand } from '../multi-command';
|
||||
|
||||
export type RedisClusterClientOptions = Omit<RedisClientOptions<{}, {}>, 'modules' | 'scripts'>;
|
||||
|
||||
export interface RedisClusterOptions<M = {}, S = {}> {
|
||||
rootNodes: Array<RedisClusterClientOptions>;
|
||||
defaults?: Partial<RedisClusterClientOptions>;
|
||||
export interface RedisClusterPlugins<M extends RedisModules, S extends RedisScripts> {
|
||||
modules?: M;
|
||||
scripts?: S;
|
||||
}
|
||||
|
||||
export interface RedisClusterOptions<M extends RedisModules, S extends RedisScripts> extends RedisClusterPlugins<M, S> {
|
||||
rootNodes: Array<RedisClusterClientOptions>;
|
||||
defaults?: Partial<RedisClusterClientOptions>;
|
||||
useReplicas?: boolean;
|
||||
maxCommandRedirections?: number;
|
||||
}
|
||||
|
||||
export type RedisClusterType<M extends RedisModules = {}, S extends RedisLuaScripts = {}> =
|
||||
WithPlugins<M, S> & RedisCluster<M, S>;
|
||||
type WithCommands = {
|
||||
[P in keyof typeof COMMANDS]: RedisClientCommandSignature<(typeof COMMANDS)[P]>;
|
||||
};
|
||||
|
||||
export default class RedisCluster<M extends RedisModules = {}, S extends RedisLuaScripts = {}> extends EventEmitter {
|
||||
static #extractFirstKey(command: RedisCommand, originalArgs: Array<unknown>, redisArgs: TransformArgumentsReply): string | Buffer | undefined {
|
||||
export type RedisClusterType<M extends RedisModules = {}, S extends RedisScripts = {}> =
|
||||
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): string | Buffer | undefined {
|
||||
if (command.FIRST_KEY_INDEX === undefined) {
|
||||
return undefined;
|
||||
} else if (typeof command.FIRST_KEY_INDEX === 'number') {
|
||||
@ -31,7 +39,7 @@ export default class RedisCluster<M extends RedisModules = {}, S extends RedisLu
|
||||
return command.FIRST_KEY_INDEX(...originalArgs);
|
||||
}
|
||||
|
||||
static create<M extends RedisModules = {}, S extends RedisLuaScripts = {}>(options?: RedisClusterOptions<M, S>): RedisClusterType<M, S> {
|
||||
static create<M extends RedisModules = {}, S extends RedisScripts = {}>(options?: RedisClusterOptions<M, S>): RedisClusterType<M, S> {
|
||||
return new (<any>extendWithModulesAndScripts({
|
||||
BaseClass: RedisCluster,
|
||||
modules: options?.modules,
|
||||
@ -41,20 +49,20 @@ export default class RedisCluster<M extends RedisModules = {}, S extends RedisLu
|
||||
}))(options);
|
||||
}
|
||||
|
||||
readonly #options: RedisClusterOptions;
|
||||
readonly #options: RedisClusterOptions<M, S>;
|
||||
readonly #slots: RedisClusterSlots<M, S>;
|
||||
readonly #Multi: new (...args: ConstructorParameters<typeof RedisMultiCommand>) => RedisMultiCommandType<M, S>;
|
||||
readonly #Multi: new (...args: ConstructorParameters<typeof RedisClusterMultiCommand>) => RedisClusterMultiCommandType<M, S>;
|
||||
|
||||
constructor(options: RedisClusterOptions<M, S>) {
|
||||
super();
|
||||
|
||||
this.#options = options;
|
||||
this.#slots = new RedisClusterSlots(options, err => this.emit('error', err));
|
||||
this.#Multi = RedisMultiCommand.extend(options);
|
||||
this.#Multi = RedisClusterMultiCommand.extend(options);
|
||||
}
|
||||
|
||||
duplicate(): RedisClusterOptions<M, S> {
|
||||
return new (Object.getPrototypeOf(this).constructor)(this.#options);
|
||||
duplicate<M extends RedisModules, S extends RedisScripts>(): RedisClusterType<M, S> {
|
||||
return new (Object.getPrototypeOf(this).constructor)();
|
||||
}
|
||||
|
||||
async connect(): Promise<void> {
|
||||
@ -67,7 +75,7 @@ export default class RedisCluster<M extends RedisModules = {}, S extends RedisLu
|
||||
return transformCommandReply(
|
||||
command,
|
||||
await this.sendCommand(
|
||||
RedisCluster.#extractFirstKey(command, args, redisArgs),
|
||||
RedisCluster.extractFirstKey(command, args, redisArgs),
|
||||
command.IS_READ_ONLY,
|
||||
redisArgs,
|
||||
options,
|
||||
@ -80,7 +88,7 @@ export default class RedisCluster<M extends RedisModules = {}, S extends RedisLu
|
||||
async sendCommand<C extends RedisCommand>(
|
||||
firstKey: string | Buffer | undefined,
|
||||
isReadonly: boolean | undefined,
|
||||
args: TransformArgumentsReply,
|
||||
args: RedisCommandArguments,
|
||||
options?: ClientCommandOptions,
|
||||
bufferMode?: boolean,
|
||||
redirections = 0
|
||||
@ -101,7 +109,7 @@ export default class RedisCluster<M extends RedisModules = {}, S extends RedisLu
|
||||
}
|
||||
}
|
||||
|
||||
async scriptsExecutor(script: RedisLuaScript, args: Array<unknown>): Promise<RedisCommandReply<typeof script>> {
|
||||
async scriptsExecutor(script: RedisScript, args: Array<unknown>): Promise<RedisCommandReply<typeof script>> {
|
||||
const { args: redisArgs, options } = transformCommandArguments<ClientCommandOptions>(script, args);
|
||||
|
||||
return transformCommandReply(
|
||||
@ -117,14 +125,14 @@ export default class RedisCluster<M extends RedisModules = {}, S extends RedisLu
|
||||
}
|
||||
|
||||
async executeScript(
|
||||
script: RedisLuaScript,
|
||||
script: RedisScript,
|
||||
originalArgs: Array<unknown>,
|
||||
redisArgs: TransformArgumentsReply,
|
||||
redisArgs: RedisCommandArguments,
|
||||
options?: ClientCommandOptions,
|
||||
redirections = 0
|
||||
): Promise<RedisCommandReply<typeof script>> {
|
||||
const client = this.#slots.getClient(
|
||||
RedisCluster.#extractFirstKey(script, originalArgs, redisArgs),
|
||||
RedisCluster.extractFirstKey(script, originalArgs, redisArgs),
|
||||
script.IS_READ_ONLY
|
||||
);
|
||||
|
||||
@ -169,20 +177,14 @@ export default class RedisCluster<M extends RedisModules = {}, S extends RedisLu
|
||||
throw err;
|
||||
}
|
||||
|
||||
multi(routing: string): RedisMultiCommandType<M, S> {
|
||||
multi(routing?: string | Buffer): RedisClusterMultiCommandType<M, S> {
|
||||
return new this.#Multi(
|
||||
async (commands: Array<MultiQueuedCommand>, chainId?: symbol) => {
|
||||
const client = this.#slots.getClient(routing);
|
||||
|
||||
return Promise.all(
|
||||
commands.map(({ args }) => {
|
||||
return client.sendCommand(args, RedisClient.commandOptions({
|
||||
chainId
|
||||
}));
|
||||
})
|
||||
);
|
||||
async (commands: Array<RedisMultiQueuedCommand>, firstKey?: string | Buffer, chainId?: symbol) => {
|
||||
return this.#slots
|
||||
.getClient(firstKey)
|
||||
.multiExecutor(commands, chainId);
|
||||
},
|
||||
this.#options
|
||||
routing
|
||||
);
|
||||
}
|
||||
|
||||
@ -199,4 +201,8 @@ export default class RedisCluster<M extends RedisModules = {}, S extends RedisLu
|
||||
}
|
||||
}
|
||||
|
||||
extendWithDefaultCommands(RedisCluster, RedisCluster.prototype.commandsExecutor);
|
||||
extendWithCommands({
|
||||
BaseClass: RedisCluster,
|
||||
commands: COMMANDS,
|
||||
executor: RedisCluster.prototype.commandsExecutor
|
||||
});
|
112
lib/cluster/multi-command.ts
Normal file
112
lib/cluster/multi-command.ts
Normal file
@ -0,0 +1,112 @@
|
||||
import COMMANDS from './commands';
|
||||
import { RedisCommand, RedisCommandArguments, RedisCommandRawReply, RedisModules, RedisPlugins, RedisScript, RedisScripts } from '../commands';
|
||||
import RedisMultiCommand, { RedisMultiQueuedCommand } from '../multi-command';
|
||||
import { extendWithCommands, extendWithModulesAndScripts } from '../commander';
|
||||
import RedisCluster from '.';
|
||||
|
||||
type RedisClusterMultiCommandSignature<C extends RedisCommand, M extends RedisModules, S extends RedisScripts> =
|
||||
(...args: Parameters<C['transformArguments']>) => RedisClusterMultiCommandType<M, S>;
|
||||
|
||||
type WithCommands<M extends RedisModules, S extends RedisScripts> = {
|
||||
[P in keyof typeof COMMANDS]: RedisClusterMultiCommandSignature<(typeof COMMANDS)[P], M, S>
|
||||
};
|
||||
|
||||
type WithModules<M extends RedisModules, S extends RedisScripts> = {
|
||||
[P in keyof M]: {
|
||||
[C in keyof M[P]]: RedisClusterMultiCommandSignature<M[P][C], M, S>;
|
||||
};
|
||||
};
|
||||
|
||||
type WithScripts<M extends RedisModules, S extends RedisScripts> = {
|
||||
[P in keyof S]: RedisClusterMultiCommandSignature<S[P], M, S>
|
||||
};
|
||||
|
||||
export type RedisClusterMultiCommandType<M extends RedisModules = {}, S extends RedisScripts = {}> =
|
||||
RedisClusterMultiCommand & WithCommands<M, S> & WithModules<M, S> & WithScripts<M, S>;
|
||||
|
||||
export type RedisClusterMultiExecutor = (queue: Array<RedisMultiQueuedCommand>, firstKey?: string | Buffer, chainId?: symbol) => Promise<Array<RedisCommandRawReply>>;
|
||||
|
||||
export default class RedisClusterMultiCommand {
|
||||
readonly #multi = new RedisMultiCommand();
|
||||
readonly #executor: RedisClusterMultiExecutor;
|
||||
#firstKey: string | Buffer | undefined;
|
||||
|
||||
static extend<M extends RedisModules, S extends RedisScripts>(
|
||||
plugins?: RedisPlugins<M, S>
|
||||
): new (...args: ConstructorParameters<typeof RedisMultiCommand>) => RedisClusterMultiCommandType<M, S> {
|
||||
return <any>extendWithModulesAndScripts({
|
||||
BaseClass: RedisClusterMultiCommand,
|
||||
modules: plugins?.modules,
|
||||
modulesCommandsExecutor: RedisClusterMultiCommand.prototype.commandsExecutor,
|
||||
scripts: plugins?.scripts,
|
||||
scriptsExecutor: RedisClusterMultiCommand.prototype.scriptsExecutor
|
||||
});
|
||||
}
|
||||
|
||||
constructor(executor: RedisClusterMultiExecutor, firstKey?: string | Buffer) {
|
||||
this.#executor = executor;
|
||||
this.#firstKey = firstKey;
|
||||
}
|
||||
|
||||
commandsExecutor(command: RedisCommand, args: Array<unknown>): this {
|
||||
const transformedArguments = command.transformArguments(...args);
|
||||
if (!this.#firstKey) {
|
||||
this.#firstKey = RedisCluster.extractFirstKey(command, args, transformedArguments);
|
||||
}
|
||||
|
||||
return this.addCommand(
|
||||
undefined,
|
||||
transformedArguments,
|
||||
command.transformReply
|
||||
);
|
||||
}
|
||||
|
||||
addCommand(
|
||||
firstKey: string | Buffer | undefined,
|
||||
args: RedisCommandArguments,
|
||||
transformReply?: RedisCommand['transformReply']
|
||||
): this {
|
||||
if (!this.#firstKey) {
|
||||
this.#firstKey = firstKey;
|
||||
}
|
||||
|
||||
this.#multi.addCommand(args, transformReply);
|
||||
return this;
|
||||
}
|
||||
|
||||
scriptsExecutor(script: RedisScript, args: Array<unknown>): this {
|
||||
const transformedArguments = this.#multi.addScript(script, args);
|
||||
if (!this.#firstKey) {
|
||||
this.#firstKey = RedisCluster.extractFirstKey(script, args, transformedArguments);
|
||||
}
|
||||
|
||||
return this.addCommand(undefined, transformedArguments);
|
||||
}
|
||||
|
||||
async exec(execAsPipeline = false): Promise<Array<RedisCommandRawReply>> {
|
||||
if (execAsPipeline) {
|
||||
return this.execAsPipeline();
|
||||
}
|
||||
|
||||
const commands = this.#multi.exec();
|
||||
if (!commands) return [];
|
||||
|
||||
return this.#multi.handleExecReplies(
|
||||
await this.#executor(commands, this.#firstKey, RedisMultiCommand.generateChainId())
|
||||
);
|
||||
}
|
||||
|
||||
EXEC = this.exec;
|
||||
|
||||
async execAsPipeline(): Promise<Array<RedisCommandRawReply>> {
|
||||
return this.#multi.transformReplies(
|
||||
await this.#executor(this.#multi.queue, this.#firstKey)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extendWithCommands({
|
||||
BaseClass: RedisClusterMultiCommand,
|
||||
commands: COMMANDS,
|
||||
executor: RedisClusterMultiCommand.prototype.commandsExecutor
|
||||
});
|
@ -1,37 +1,32 @@
|
||||
|
||||
import COMMANDS, { RedisCommand, RedisCommandReply, RedisModules, RedisReply, TransformArgumentsReply } from './commands';
|
||||
import { RedisLuaScript, RedisLuaScripts } from './lua-script';
|
||||
import { CommandOptions, isCommandOptions } from './command-options';
|
||||
import { RedisCommand, RedisCommandArguments, RedisCommandRawReply, RedisCommandReply, RedisCommands, RedisModules, RedisScript, RedisScripts } from './commands';
|
||||
|
||||
type Instantiable<T = any> = new(...args: Array<any>) => T;
|
||||
|
||||
type CommandExecutor<T extends Instantiable = Instantiable> = (this: InstanceType<T>, command: RedisCommand, args: Array<unknown>) => unknown;
|
||||
interface ExtendWithCommandsConfig<T extends Instantiable> {
|
||||
BaseClass: T;
|
||||
commands: RedisCommands;
|
||||
executor(command: RedisCommand, args: Array<unknown>): unknown;
|
||||
}
|
||||
|
||||
export function extendWithDefaultCommands<T extends Instantiable>(BaseClass: T, executor: CommandExecutor<T>): void {
|
||||
for (const [name, command] of Object.entries(COMMANDS)) {
|
||||
export function extendWithCommands<T extends Instantiable>({ BaseClass, commands, executor }: ExtendWithCommandsConfig<T>): void {
|
||||
for (const [name, command] of Object.entries(commands)) {
|
||||
BaseClass.prototype[name] = function (...args: Array<unknown>): unknown {
|
||||
return executor.call(this, command, args);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
interface ExtendWithModulesAndScriptsConfig<
|
||||
T extends Instantiable,
|
||||
M extends RedisModules,
|
||||
S extends RedisLuaScripts
|
||||
> {
|
||||
interface ExtendWithModulesAndScriptsConfig<T extends Instantiable> {
|
||||
BaseClass: T;
|
||||
modules: M | undefined;
|
||||
modulesCommandsExecutor: CommandExecutor<T>;
|
||||
scripts: S | undefined;
|
||||
scriptsExecutor(this: InstanceType<T>, script: RedisLuaScript, args: Array<unknown>): unknown;
|
||||
modules?: RedisModules;
|
||||
modulesCommandsExecutor(this: InstanceType<T>, command: RedisCommand, args: Array<unknown>): unknown;
|
||||
scripts?: RedisScripts;
|
||||
scriptsExecutor(this: InstanceType<T>, script: RedisScript, args: Array<unknown>): unknown;
|
||||
}
|
||||
|
||||
export function extendWithModulesAndScripts<
|
||||
T extends Instantiable,
|
||||
M extends RedisModules,
|
||||
S extends RedisLuaScripts,
|
||||
>(config: ExtendWithModulesAndScriptsConfig<T, M, S>): T {
|
||||
export function extendWithModulesAndScripts<T extends Instantiable>(config: ExtendWithModulesAndScriptsConfig<T>): T {
|
||||
let Commander: T | undefined;
|
||||
|
||||
if (config.modules) {
|
||||
@ -39,7 +34,7 @@ export function extendWithModulesAndScripts<
|
||||
constructor(...args: Array<any>) {
|
||||
super(...args);
|
||||
|
||||
for (const module of Object.keys(config.modules as RedisModules)) {
|
||||
for (const module of Object.keys(config.modules!)) {
|
||||
this[module] = new this[module](this);
|
||||
}
|
||||
}
|
||||
@ -79,7 +74,7 @@ export function transformCommandArguments<T = unknown>(
|
||||
command: RedisCommand,
|
||||
args: Array<unknown>
|
||||
): {
|
||||
args: TransformArgumentsReply;
|
||||
args: RedisCommandArguments;
|
||||
options: CommandOptions<T> | undefined;
|
||||
} {
|
||||
let options;
|
||||
@ -96,7 +91,7 @@ export function transformCommandArguments<T = unknown>(
|
||||
|
||||
const DELIMITER = '\r\n';
|
||||
|
||||
export function* encodeCommand(args: TransformArgumentsReply): IterableIterator<string | Buffer> {
|
||||
export function* encodeCommand(args: RedisCommandArguments): IterableIterator<string | Buffer> {
|
||||
yield `*${args.length}${DELIMITER}`;
|
||||
|
||||
for (const arg of args) {
|
||||
@ -107,7 +102,11 @@ export function* encodeCommand(args: TransformArgumentsReply): IterableIterator<
|
||||
}
|
||||
}
|
||||
|
||||
export function transformCommandReply(command: RedisCommand, rawReply: RedisReply, preserved: unknown): RedisCommandReply<typeof command> {
|
||||
export function transformCommandReply(
|
||||
command: RedisCommand,
|
||||
rawReply: RedisCommandRawReply,
|
||||
preserved: unknown
|
||||
): RedisCommandReply<typeof command> {
|
||||
if (!command.transformReply) {
|
||||
return rawReply;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export function transformArguments(username: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(username: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['ACL', 'DELUSER'], username);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export function transformArguments(username: string, rule: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(username: string, rule: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['ACL', 'SETUSER', username], rule);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
|
||||
type BitOperations = 'AND' | 'OR' | 'XOR' | 'NOT';
|
||||
|
||||
export function transformArguments(operation: BitOperations, destKey: string, key: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(operation: BitOperations, destKey: string, key: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['BITOP', operation, destKey], key);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(keys: string | Buffer | Array<string | Buffer>, timeout: number): TransformArgumentsReply {
|
||||
export function transformArguments(keys: string | Buffer | Array<string | Buffer>, timeout: number): RedisCommandArguments {
|
||||
const args = pushVerdictArguments(['BLPOP'], keys);
|
||||
|
||||
args.push(timeout.toString());
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): TransformArgumentsReply {
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): RedisCommandArguments {
|
||||
const args = pushVerdictArguments(['BRPOP'], key);
|
||||
|
||||
args.push(timeout.toString());
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumberInfinity, ZMember } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): TransformArgumentsReply {
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): RedisCommandArguments {
|
||||
const args = pushVerdictArguments(['BZPOPMAX'], key);
|
||||
|
||||
args.push(timeout.toString());
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumberInfinity, ZMember } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): TransformArgumentsReply {
|
||||
export function transformArguments(key: string | Array<string>, timeout: number): RedisCommandArguments {
|
||||
const args = pushVerdictArguments(['BZPOPMIN'], key);
|
||||
|
||||
args.push(timeout.toString());
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { itWithCluster, TestRedisClusters } from '../test-utils';
|
||||
import { transformArguments, transformReply } from './CLUSTER_INFO';
|
||||
|
||||
describe('CLUSTER INFO', () => {
|
||||
@ -44,21 +43,4 @@ describe('CLUSTER INFO', () => {
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.clusterInfo', async cluster => {
|
||||
const info = await cluster.clusterInfo();
|
||||
assert.equal(info.state, 'ok');
|
||||
assert.deepEqual(info.slots, {
|
||||
assigned: 16384,
|
||||
ok: 16384,
|
||||
pfail: 0,
|
||||
fail: 0
|
||||
});
|
||||
assert.equal(info.knownNodes, 3);
|
||||
assert.equal(info.size, 3);
|
||||
assert.equal(typeof info.currentEpoch, 'number');
|
||||
assert.equal(typeof info.myEpoch, 'number');
|
||||
assert.equal(typeof info.stats.messagesReceived, 'number');
|
||||
assert.equal(typeof info.stats.messagesSent, 'number');
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { itWithCluster, TestRedisClusters } from '../test-utils';
|
||||
import { RedisClusterNodeLinkStates, transformArguments, transformReply } from './CLUSTER_NODES';
|
||||
|
||||
describe('CLUSTER NODES', () => {
|
||||
@ -93,24 +92,4 @@ describe('CLUSTER NODES', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.clusterNodes', async cluster => {
|
||||
for (const node of (await cluster.clusterNodes())) {
|
||||
assert.equal(typeof node.id, 'string');
|
||||
assert.equal(typeof node.url, 'string');
|
||||
assert.equal(typeof node.host, 'string');
|
||||
assert.equal(typeof node.port, 'number');
|
||||
assert.equal(typeof node.cport, 'number');
|
||||
assert.ok(Array.isArray(node.flags));
|
||||
assert.equal(typeof node.pingSent, 'number');
|
||||
assert.equal(typeof node.pongRecv, 'number');
|
||||
assert.equal(typeof node.configEpoch, 'number');
|
||||
assert.equal(typeof node.linkState, 'string');
|
||||
|
||||
for (const slot of node.slots) {
|
||||
assert.equal(typeof slot.from, 'number');
|
||||
assert.equal(typeof slot.to, 'number');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
|
||||
export function transformArguments(): TransformArgumentsReply {
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['CLUSTER', 'SLOTS'];
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { CommandRawReply, CommandReply, transformCommandReply } from './generic-transformers';
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(): TransformArgumentsReply {
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['COMMAND'];
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { itWithClient, itWithCluster, TestRedisClusters, TestRedisServers } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './COMMAND_COUNT';
|
||||
|
||||
describe('COMMAND COUNT', () => {
|
||||
@ -16,11 +16,4 @@ describe('COMMAND COUNT', () => {
|
||||
'number'
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.commandCount', async cluster => {
|
||||
assert.equal(
|
||||
typeof await cluster.commandCount(),
|
||||
'number'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(): TransformArgumentsReply {
|
||||
export function transformArguments(): RedisCommandArguments {
|
||||
return ['COMMAND', 'COUNT'];
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { itWithClient, itWithCluster, TestRedisClusters, TestRedisServers } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './COMMAND_GETKEYS';
|
||||
|
||||
describe('COMMAND GETKEYS', () => {
|
||||
@ -16,11 +16,4 @@ describe('COMMAND GETKEYS', () => {
|
||||
['key']
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.commandGetKeys', async cluster => {
|
||||
assert.deepEqual(
|
||||
await cluster.commandGetKeys(['GET', 'key']),
|
||||
['key']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(args: Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(args: Array<string>): RedisCommandArguments {
|
||||
return ['COMMAND', 'GETKEYS', ...args];
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { CommandRawReply, CommandReply, transformCommandReply } from './generic-transformers';
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(commands: Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(commands: Array<string>): RedisCommandArguments {
|
||||
return ['COMMAND', 'INFO', ...commands];
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './DBSIZE';
|
||||
|
||||
describe('DBSIZE', () => {
|
||||
@ -16,11 +16,4 @@ describe('DBSIZE', () => {
|
||||
0
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.dbSize', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.dbSize(),
|
||||
0
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(keys: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['DEL'], keys);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './ECHO';
|
||||
|
||||
describe('ECHO', () => {
|
||||
@ -16,11 +16,4 @@ describe('ECHO', () => {
|
||||
'message'
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.echo', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.echo('message'),
|
||||
'message'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments, transformReplyBoolean } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(keys: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['EXISTS'], keys);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, member: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, member: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['GEOHASH', key], member);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, member: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, member: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['GEOPOS', key], member);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster, describeHandleMinimumRedisVersion } from '../test-utils';
|
||||
import { GeoReplyWith } from './generic-transformers';
|
||||
import { transformArguments } from './GEOSEARCH_WITH';
|
||||
@ -8,7 +8,7 @@ describe('GEOSEARCH WITH', () => {
|
||||
describeHandleMinimumRedisVersion([6, 2]);
|
||||
|
||||
it('transformArguments', () => {
|
||||
const expectedReply: TransformArgumentsReply = ['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'WITHDIST']
|
||||
const expectedReply: RedisCommandArguments = ['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'WITHDIST']
|
||||
expectedReply.preserve = ['WITHDIST'];
|
||||
|
||||
assert.deepEqual(
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { GeoSearchFrom, GeoSearchBy, GeoReplyWith, GeoSearchOptions, transformGeoMembersWithReply } from './generic-transformers';
|
||||
import { transformArguments as geoSearchTransformArguments } from './GEOSEARCH';
|
||||
|
||||
@ -10,8 +10,8 @@ export function transformArguments(
|
||||
by: GeoSearchBy,
|
||||
replyWith: Array<GeoReplyWith>,
|
||||
options?: GeoSearchOptions
|
||||
): TransformArgumentsReply {
|
||||
const args: TransformArgumentsReply = geoSearchTransformArguments(key, from, by, options);
|
||||
): RedisCommandArguments {
|
||||
const args: RedisCommandArguments = geoSearchTransformArguments(key, from, by, options);
|
||||
|
||||
args.push(...replyWith);
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string | Buffer): TransformArgumentsReply {
|
||||
export function transformArguments(key: string | Buffer): RedisCommandArguments {
|
||||
return ['GET', key];
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { transformEXAT, transformPXAT } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@ -15,7 +15,7 @@ type GetExModes = {
|
||||
PERSIST: true;
|
||||
};
|
||||
|
||||
export function transformArguments(key: string, mode: GetExModes): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, mode: GetExModes): RedisCommandArguments {
|
||||
const args = ['GETEX', key];
|
||||
|
||||
if ('EX' in mode) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, field: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, field: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['HDEL', key], field);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, fields: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, fields: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['HMGET', key], fields);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
|
||||
type HSETObject = Record<string | number, string | number>;
|
||||
|
||||
@ -14,7 +14,7 @@ type SingleFieldArguments = [...generic: GenericArguments, field: string, value:
|
||||
|
||||
type MultipleFieldsArguments = [...generic: GenericArguments, value: HSETObject | HSETMap | HSETTuples];
|
||||
|
||||
export function transformArguments(...[ key, value, fieldValue ]: SingleFieldArguments | MultipleFieldsArguments): TransformArgumentsReply {
|
||||
export function transformArguments(...[ key, value, fieldValue ]: SingleFieldArguments | MultipleFieldsArguments): RedisCommandArguments {
|
||||
const args = ['HSET', key];
|
||||
|
||||
if (typeof value === 'string') {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './LASTSAVE';
|
||||
|
||||
describe('LASTSAVE', () => {
|
||||
@ -13,8 +13,4 @@ describe('LASTSAVE', () => {
|
||||
itWithClient(TestRedisServers.OPEN, 'client.lastSave', async client => {
|
||||
assert.ok((await client.lastSave()) instanceof Date);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lastSave', async cluster => {
|
||||
assert.ok((await cluster.lastSave()) instanceof Date);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './LOLWUT';
|
||||
|
||||
describe('LOLWUT', () => {
|
||||
@ -33,11 +33,4 @@ describe('LOLWUT', () => {
|
||||
'string'
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.LOLWUT', async cluster => {
|
||||
assert.equal(
|
||||
typeof (await cluster.LOLWUT()),
|
||||
'string'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, elements: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, elements: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['LPUSH', key], elements);}
|
||||
|
||||
export declare function transformReply(): number;
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, element: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, element: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['LPUSHX', key], element);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './MEMORY_DOCTOR';
|
||||
|
||||
describe('MEMORY DOCTOR', () => {
|
||||
@ -16,11 +16,4 @@ describe('MEMORY DOCTOR', () => {
|
||||
'string'
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.memoryDoctor', async cluster => {
|
||||
assert.equal(
|
||||
typeof (await cluster.memoryDoctor()),
|
||||
'string'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './MEMORY_MALLOC-STATS';
|
||||
|
||||
describe('MEMORY MALLOC-STATS', () => {
|
||||
@ -16,11 +16,4 @@ describe('MEMORY MALLOC-STATS', () => {
|
||||
'string'
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.memoryDoctor', async cluster => {
|
||||
assert.equal(
|
||||
typeof (await cluster.memoryDoctor()),
|
||||
'string'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './MEMORY_PURGE';
|
||||
|
||||
describe('MEMORY PURGE', () => {
|
||||
@ -16,11 +16,4 @@ describe('MEMORY PURGE', () => {
|
||||
'OK'
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.memoryPurge', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.memoryPurge(),
|
||||
'OK'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './MEMORY_USAGE';
|
||||
|
||||
describe('MEMORY USAGE', () => {
|
||||
@ -27,11 +27,4 @@ describe('MEMORY USAGE', () => {
|
||||
null
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.memoryUsage', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.memoryUsage('key'),
|
||||
null
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments, transformReplyBoolean } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, element: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, element: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['PFADD', key], element);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['PFCOUNT'], key);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(destination: string, source: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(destination: string, source: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['PFMERGE', destination], source);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
|
||||
describe('PING', () => {
|
||||
itWithClient(TestRedisServers.OPEN, 'client.ping', async client => {
|
||||
@ -8,11 +8,4 @@ describe('PING', () => {
|
||||
'PONG'
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.ping', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.ping(),
|
||||
'PONG'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './PUBSUB_CHANNELS';
|
||||
|
||||
describe('PUBSUB CHANNELS', () => {
|
||||
@ -25,11 +25,4 @@ describe('PUBSUB CHANNELS', () => {
|
||||
[]
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.pubSubChannels', async cluster => {
|
||||
assert.deepEqual(
|
||||
await cluster.pubSubChannels(),
|
||||
[]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './PUBSUB_NUMPAT';
|
||||
|
||||
describe('PUBSUB NUMPAT', () => {
|
||||
@ -16,11 +16,4 @@ describe('PUBSUB NUMPAT', () => {
|
||||
0
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.pubSubNumPat', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.pubSubNumPat(),
|
||||
0
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './PUBSUB_NUMSUB';
|
||||
|
||||
describe('PUBSUB NUMSUB', () => {
|
||||
@ -32,11 +32,4 @@ describe('PUBSUB NUMSUB', () => {
|
||||
Object.create(null)
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.pubSubNumSub', async cluster => {
|
||||
assert.deepEqual(
|
||||
await cluster.pubSubNumSub(),
|
||||
Object.create(null)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, element: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, element: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['RPUSH', key], element);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, element: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, element: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['RPUSHX', key], element);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, members: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, members: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['SADD', key], members);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './SCRIPT_DEBUG';
|
||||
|
||||
describe('SCRIPT DEBUG', () => {
|
||||
@ -16,11 +16,4 @@ describe('SCRIPT DEBUG', () => {
|
||||
'OK'
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.scriptDebug', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.scriptDebug('NO'),
|
||||
'OK'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './SCRIPT_EXISTS';
|
||||
|
||||
describe('SCRIPT EXISTS', () => {
|
||||
@ -25,11 +25,4 @@ describe('SCRIPT EXISTS', () => {
|
||||
[false]
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.scriptExists', async cluster => {
|
||||
assert.deepEqual(
|
||||
await cluster.scriptExists('sha1'),
|
||||
[false]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments, transformReplyBooleanArray } from './generic-transformers';
|
||||
|
||||
export function transformArguments(sha1: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(sha1: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['SCRIPT', 'EXISTS'], sha1);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './SCRIPT_FLUSH';
|
||||
|
||||
describe('SCRIPT FLUSH', () => {
|
||||
@ -25,11 +25,4 @@ describe('SCRIPT FLUSH', () => {
|
||||
'OK'
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.scriptFlush', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.scriptFlush(),
|
||||
'OK'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { scriptSha1 } from '../lua-script';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './SCRIPT_LOAD';
|
||||
|
||||
describe('SCRIPT LOAD', () => {
|
||||
@ -20,11 +20,4 @@ describe('SCRIPT LOAD', () => {
|
||||
SCRIPT_SHA1
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.scriptLoad', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.scriptLoad(SCRIPT),
|
||||
SCRIPT_SHA1
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(keys: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['SDIFF'], keys);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['SDIFFSTORE', destination], keys);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
@ -40,7 +40,7 @@ interface SetCommonOptions {
|
||||
|
||||
type SetOptions = SetTTL & SetGuards & (SetCommonOptions | {});
|
||||
|
||||
export function transformArguments(key: string | Buffer, value: string | Buffer, options?: SetOptions): TransformArgumentsReply {
|
||||
export function transformArguments(key: string | Buffer, value: string | Buffer, options?: SetOptions): RedisCommandArguments {
|
||||
const args = ['SET', key, value];
|
||||
|
||||
if (!options) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { BitValue } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, offset: number, value: BitValue): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, offset: number, value: BitValue): RedisCommandArguments {
|
||||
return ['SETBIT', key, offset.toString(), value.toString()];
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Buffer, seconds: number, value: string): TransformArgumentsReply {
|
||||
export function transformArguments(key: string | Buffer, seconds: number, value: string): RedisCommandArguments {
|
||||
return [
|
||||
'SETEX',
|
||||
key,
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(keys: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['SINTER'], keys);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['SINTERSTORE', destination], keys);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, members: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, members: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['SREM', key], members);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(keys: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(keys: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['SUNION'], keys);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(destination: string, keys: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['SUNIONSTORE', destination], keys);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['TOUCH'], key);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['UNLINK'], key);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
||||
import { transformArguments } from './UNWATCH';
|
||||
|
||||
describe('UNWATCH', () => {
|
||||
@ -16,11 +16,4 @@ describe('UNWATCH', () => {
|
||||
'OK'
|
||||
);
|
||||
});
|
||||
|
||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.unwatch', async cluster => {
|
||||
assert.equal(
|
||||
await cluster.unwatch(),
|
||||
'OK'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export function transformArguments(key: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['WATCH'], key);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, group: string, id: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, group: string, id: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['XACK', key, group], id);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, id: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, id: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['XDEL', key], id);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArgument } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(keys: Array<string> | string): TransformArgumentsReply {
|
||||
export function transformArguments(keys: Array<string> | string): RedisCommandArguments {
|
||||
return pushVerdictArgument(['ZDIFF'], keys);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArgument } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(destination: string, keys: Array<string> | string): TransformArgumentsReply {
|
||||
export function transformArguments(destination: string, keys: Array<string> | string): RedisCommandArguments {
|
||||
return pushVerdictArgument(['ZDIFFSTORE', destination], keys);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { transformReplySortedSetWithScores } from './generic-transformers';
|
||||
import { transformArguments as transformZDiffArguments } from './ZDIFF';
|
||||
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './ZDIFF';
|
||||
|
||||
export function transformArguments(...args: Parameters<typeof transformZDiffArguments>): TransformArgumentsReply {
|
||||
export function transformArguments(...args: Parameters<typeof transformZDiffArguments>): RedisCommandArguments {
|
||||
return [
|
||||
...transformZDiffArguments(...args),
|
||||
'WITHSCORES'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArgument } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
@ -10,7 +10,7 @@ interface ZInterOptions {
|
||||
AGGREGATE?: 'SUM' | 'MIN' | 'MAX';
|
||||
}
|
||||
|
||||
export function transformArguments(keys: Array<string> | string, options?: ZInterOptions): TransformArgumentsReply {
|
||||
export function transformArguments(keys: Array<string> | string, options?: ZInterOptions): RedisCommandArguments {
|
||||
const args = pushVerdictArgument(['ZINTER'], keys);
|
||||
|
||||
if (options?.WEIGHTS) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArgument } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@ -8,7 +8,7 @@ interface ZInterStoreOptions {
|
||||
AGGREGATE?: 'SUM' | 'MIN' | 'MAX';
|
||||
}
|
||||
|
||||
export function transformArguments(destination: string, keys: Array<string> | string, options?: ZInterStoreOptions): TransformArgumentsReply {
|
||||
export function transformArguments(destination: string, keys: Array<string> | string, options?: ZInterStoreOptions): RedisCommandArguments {
|
||||
const args = pushVerdictArgument(['ZINTERSTORE', destination], keys);
|
||||
|
||||
if (options?.WEIGHTS) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { transformReplySortedSetWithScores } from './generic-transformers';
|
||||
import { transformArguments as transformZInterArguments } from './ZINTER';
|
||||
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './ZINTER';
|
||||
|
||||
export function transformArguments(...args: Parameters<typeof transformZInterArguments>): TransformArgumentsReply {
|
||||
export function transformArguments(...args: Parameters<typeof transformZInterArguments>): RedisCommandArguments {
|
||||
return [
|
||||
...transformZInterArguments(...args),
|
||||
'WITHSCORES'
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments, transformReplyNumberInfinityNullArray } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string, member: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, member: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['ZMSCORE', key], member);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { transformArgumentNumberInfinity } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@ -17,7 +17,7 @@ export function transformArguments(
|
||||
min: number | string,
|
||||
max: number | string,
|
||||
options?: ZRangeByLexOptions
|
||||
): TransformArgumentsReply {
|
||||
): RedisCommandArguments {
|
||||
const args = [
|
||||
'ZRANGEBYLEX',
|
||||
key,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { transformArgumentNumberInfinity } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@ -17,7 +17,7 @@ export function transformArguments(
|
||||
min: number | string,
|
||||
max: number | string,
|
||||
options?: ZRangeByScoreOptions
|
||||
): TransformArgumentsReply {
|
||||
): RedisCommandArguments {
|
||||
const args = [
|
||||
'ZRANGEBYSCORE',
|
||||
key,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { transformReplySortedSetWithScores } from './generic-transformers';
|
||||
import { ZRangeByScoreOptions, transformArguments as transformZRangeByScoreArguments } from './ZRANGEBYSCORE';
|
||||
|
||||
@ -9,7 +9,7 @@ export function transformArguments(
|
||||
min: number | string,
|
||||
max: number | string,
|
||||
options?: ZRangeByScoreOptions
|
||||
): TransformArgumentsReply {
|
||||
): RedisCommandArguments {
|
||||
return [
|
||||
...transformZRangeByScoreArguments(key, min, max, options),
|
||||
'WITHSCORES'
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArguments } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export function transformArguments(key: string, member: string | Array<string>): TransformArgumentsReply {
|
||||
export function transformArguments(key: string, member: string | Array<string>): RedisCommandArguments {
|
||||
return pushVerdictArguments(['ZREM', key], member);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArgument } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 2;
|
||||
@ -10,7 +10,7 @@ interface ZUnionOptions {
|
||||
AGGREGATE?: 'SUM' | 'MIN' | 'MAX';
|
||||
}
|
||||
|
||||
export function transformArguments(keys: Array<string> | string, options?: ZUnionOptions): TransformArgumentsReply {
|
||||
export function transformArguments(keys: Array<string> | string, options?: ZUnionOptions): RedisCommandArguments {
|
||||
const args = pushVerdictArgument(['ZUNION'], keys);
|
||||
|
||||
if (options?.WEIGHTS) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { pushVerdictArgument } from './generic-transformers';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
@ -8,7 +8,7 @@ interface ZUnionOptions {
|
||||
AGGREGATE?: 'SUM' | 'MIN' | 'MAX';
|
||||
}
|
||||
|
||||
export function transformArguments(destination: string, keys: Array<string> | string, options?: ZUnionOptions): TransformArgumentsReply {
|
||||
export function transformArguments(destination: string, keys: Array<string> | string, options?: ZUnionOptions): RedisCommandArguments {
|
||||
const args = pushVerdictArgument(['ZUNIONSTORE', destination], keys);
|
||||
|
||||
if (options?.WEIGHTS) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
import { transformReplySortedSetWithScores } from './generic-transformers';
|
||||
import { transformArguments as transformZUnionArguments } from './ZUNION';
|
||||
|
||||
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './ZUNION';
|
||||
|
||||
export function transformArguments(...args: Parameters<typeof transformZUnionArguments>): TransformArgumentsReply {
|
||||
export function transformArguments(...args: Parameters<typeof transformZUnionArguments>): RedisCommandArguments {
|
||||
return [
|
||||
...transformZUnionArguments(...args),
|
||||
'WITHSCORES'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { TransformArgumentsReply } from '.';
|
||||
import { RedisCommandArguments } from '.';
|
||||
|
||||
export function transformReplyBoolean(reply: number): boolean {
|
||||
return reply === 1;
|
||||
@ -308,7 +308,7 @@ export function pushStringTuplesArguments(args: Array<string>, tuples: StringTup
|
||||
return args;
|
||||
}
|
||||
|
||||
export function pushVerdictArguments(args: TransformArgumentsReply, value: string | Buffer | Array<string | Buffer>): TransformArgumentsReply {
|
||||
export function pushVerdictArguments(args: RedisCommandArguments, value: string | Buffer | Array<string | Buffer>): RedisCommandArguments {
|
||||
if (Array.isArray(value)) {
|
||||
args.push(...value);
|
||||
} else {
|
||||
@ -318,7 +318,7 @@ export function pushVerdictArguments(args: TransformArgumentsReply, value: strin
|
||||
return args;
|
||||
}
|
||||
|
||||
export function pushVerdictArgument(args: TransformArgumentsReply, value: string | Array<string>): TransformArgumentsReply {
|
||||
export function pushVerdictArgument(args: RedisCommandArguments, value: string | Array<string>): RedisCommandArguments {
|
||||
if (typeof value === 'string') {
|
||||
args.push('1', value);
|
||||
} else {
|
||||
@ -328,7 +328,7 @@ export function pushVerdictArgument(args: TransformArgumentsReply, value: string
|
||||
return args;
|
||||
}
|
||||
|
||||
export function pushOptionalVerdictArgument(args: TransformArgumentsReply, name: string, value: undefined | string | Array<string>): TransformArgumentsReply {
|
||||
export function pushOptionalVerdictArgument(args: RedisCommandArguments, name: string, value: undefined | string | Array<string>): RedisCommandArguments {
|
||||
if (value === undefined) return args;
|
||||
|
||||
args.push(name);
|
||||
|
@ -1,778 +1,18 @@
|
||||
import * as ACL_CAT from './ACL_CAT';
|
||||
import * as ACL_DELUSER from './ACL_DELUSER';
|
||||
import * as ACL_GENPASS from './ACL_GENPASS';
|
||||
import * as ACL_GETUSER from './ACL_GETUSER';
|
||||
import * as ACL_LIST from './ACL_LIST';
|
||||
import * as ACL_LOAD from './ACL_LOAD';
|
||||
import * as ACL_LOG_RESET from './ACL_LOG_RESET';
|
||||
import * as ACL_LOG from './ACL_LOG';
|
||||
import * as ACL_SAVE from './ACL_SAVE';
|
||||
import * as ACL_SETUSER from './ACL_SETUSER';
|
||||
import * as ACL_USERS from './ACL_USERS';
|
||||
import * as ACL_WHOAMI from './ACL_WHOAMI';
|
||||
import * as APPEND from './APPEND';
|
||||
import * as ASKING from './ASKING';
|
||||
import * as AUTH from './AUTH';
|
||||
import * as BGREWRITEAOF from './BGREWRITEAOF';
|
||||
import * as BGSAVE from './BGSAVE';
|
||||
import * as BITCOUNT from './BITCOUNT';
|
||||
import * as BITFIELD from './BITFIELD';
|
||||
import * as BITOP from './BITOP';
|
||||
import * as BITPOS from './BITPOS';
|
||||
import * as BLMOVE from './BLMOVE';
|
||||
import * as BLPOP from './BLPOP';
|
||||
import * as BRPOP from './BRPOP';
|
||||
import * as BRPOPLPUSH from './BRPOPLPUSH';
|
||||
import * as BZPOPMAX from './BZPOPMAX';
|
||||
import * as BZPOPMIN from './BZPOPMIN';
|
||||
import * as CLIENT_ID from './CLIENT_ID';
|
||||
import * as CLIENT_INFO from './CLIENT_INFO';
|
||||
import * as CLUSTER_ADDSLOTS from './CLUSTER_ADDSLOTS';
|
||||
import * as CLUSTER_FLUSHSLOTS from './CLUSTER_FLUSHSLOTS';
|
||||
import * as CLUSTER_INFO from './CLUSTER_INFO';
|
||||
import * as CLUSTER_NODES from './CLUSTER_NODES';
|
||||
import * as CLUSTER_MEET from './CLUSTER_MEET';
|
||||
import * as CLUSTER_RESET from './CLUSTER_RESET';
|
||||
import * as CLUSTER_SETSLOT from './CLUSTER_SETSLOT';
|
||||
import * as CLUSTER_SLOTS from './CLUSTER_SLOTS';
|
||||
import * as COMMAND_COUNT from './COMMAND_COUNT';
|
||||
import * as COMMAND_GETKEYS from './COMMAND_GETKEYS';
|
||||
import * as COMMAND_INFO from './COMMAND_INFO';
|
||||
import * as COMMAND from './COMMAND';
|
||||
import * as CONFIG_GET from './CONFIG_GET';
|
||||
import * as CONFIG_RESETASTAT from './CONFIG_RESETSTAT';
|
||||
import * as CONFIG_REWRITE from './CONFIG_REWRITE';
|
||||
import * as CONFIG_SET from './CONFIG_SET';
|
||||
import * as COPY from './COPY';
|
||||
import * as DBSIZE from './DBSIZE';
|
||||
import * as DECR from './DECR';
|
||||
import * as DECRBY from './DECRBY';
|
||||
import * as DEL from './DEL';
|
||||
import * as DISCARD from './DISCARD';
|
||||
import * as DUMP from './DUMP';
|
||||
import * as ECHO from './ECHO';
|
||||
import * as EVAL from './EVAL';
|
||||
import * as EVALSHA from './EVALSHA';
|
||||
import * as EXISTS from './EXISTS';
|
||||
import * as EXPIRE from './EXPIRE';
|
||||
import * as EXPIREAT from './EXPIREAT';
|
||||
import * as FAILOVER from './FAILOVER';
|
||||
import * as FLUSHALL from './FLUSHALL';
|
||||
import * as FLUSHDB from './FLUSHDB';
|
||||
import * as GEOADD from './GEOADD';
|
||||
import * as GEODIST from './GEODIST';
|
||||
import * as GEOHASH from './GEOHASH';
|
||||
import * as GEOPOS from './GEOPOS';
|
||||
import * as GEOSEARCH_WITH from './GEOSEARCH_WITH';
|
||||
import * as GEOSEARCH from './GEOSEARCH';
|
||||
import * as GEOSEARCHSTORE from './GEOSEARCHSTORE';
|
||||
import * as GET_BUFFER from './GET_BUFFER';
|
||||
import * as GET from './GET';
|
||||
import * as GETBIT from './GETBIT';
|
||||
import * as GETDEL from './GETDEL';
|
||||
import * as GETEX from './GETEX';
|
||||
import * as GETRANGE from './GETRANGE';
|
||||
import * as GETSET from './GETSET';
|
||||
import * as HDEL from './HDEL';
|
||||
import * as HELLO from './HELLO';
|
||||
import * as HEXISTS from './HEXISTS';
|
||||
import * as HGET from './HGET';
|
||||
import * as HGETALL from './HGETALL';
|
||||
import * as HINCRBY from './HINCRBY';
|
||||
import * as HINCRBYFLOAT from './HINCRBYFLOAT';
|
||||
import * as HKEYS from './HKEYS';
|
||||
import * as HLEN from './HLEN';
|
||||
import * as HMGET from './HMGET';
|
||||
import * as HRANDFIELD_COUNT_WITHVALUES from './HRANDFIELD_COUNT_WITHVALUES';
|
||||
import * as HRANDFIELD_COUNT from './HRANDFIELD_COUNT';
|
||||
import * as HRANDFIELD from './HRANDFIELD';
|
||||
import * as HSCAN from './HSCAN';
|
||||
import * as HSET from './HSET';
|
||||
import * as HSETNX from './HSETNX';
|
||||
import * as HSTRLEN from './HSTRLEN';
|
||||
import * as HVALS from './HVALS';
|
||||
import * as INCR from './INCR';
|
||||
import * as INCRBY from './INCRBY';
|
||||
import * as INCRBYFLOAT from './INCRBYFLOAT';
|
||||
import * as INFO from './INFO';
|
||||
import * as KEYS from './KEYS';
|
||||
import * as LASTSAVE from './LASTSAVE';
|
||||
import * as LINDEX from './LINDEX';
|
||||
import * as LINSERT from './LINSERT';
|
||||
import * as LLEN from './LLEN';
|
||||
import * as LMOVE from './LMOVE';
|
||||
import * as LOLWUT from './LOLWUT';
|
||||
import * as LPOP_COUNT from './LPOP_COUNT';
|
||||
import * as LPOP from './LPOP';
|
||||
import * as LPOS_COUNT from './LPOS_COUNT';
|
||||
import * as LPOS from './LPOS';
|
||||
import * as LPUSH from './LPUSH';
|
||||
import * as LPUSHX from './LPUSHX';
|
||||
import * as LRANGE from './LRANGE';
|
||||
import * as LREM from './LREM';
|
||||
import * as LSET from './LSET';
|
||||
import * as LTRIM from './LTRIM';
|
||||
import * as MEMOERY_DOCTOR from './MEMORY_DOCTOR';
|
||||
import * as MEMORY_MALLOC_STATS from './MEMORY_MALLOC-STATS';
|
||||
import * as MEMORY_PURGE from './MEMORY_PURGE';
|
||||
import * as MEMORY_STATS from './MEMORY_STATS';
|
||||
import * as MEMORY_USAGE from './MEMORY_USAGE';
|
||||
import * as MGET from './MGET';
|
||||
import * as MIGRATE from './MIGRATE';
|
||||
import * as MODULE_LIST from './MODULE_LIST';
|
||||
import * as MODULE_LOAD from './MODULE_LOAD';
|
||||
import * as MODULE_UNLOAD from './MODULE_UNLOAD';
|
||||
import * as MOVE from './MOVE';
|
||||
import * as MSET from './MSET';
|
||||
import * as MSETNX from './MSETNX';
|
||||
import * as PERSIST from './PERSIST';
|
||||
import * as PEXPIRE from './PEXPIRE';
|
||||
import * as PEXPIREAT from './PEXPIREAT';
|
||||
import * as PFADD from './PFADD';
|
||||
import * as PFCOUNT from './PFCOUNT';
|
||||
import * as PFMERGE from './PFMERGE';
|
||||
import * as PING from './PING';
|
||||
import * as PSETEX from './PSETEX';
|
||||
import * as PTTL from './PTTL';
|
||||
import * as PUBLISH from './PUBLISH';
|
||||
import * as PUBSUB_CHANNELS from './PUBSUB_CHANNELS';
|
||||
import * as PUBSUB_NUMPAT from './PUBSUB_NUMPAT';
|
||||
import * as PUBSUB_NUMSUB from './PUBSUB_NUMSUB';
|
||||
import * as RANDOMKEY from './RANDOMKEY';
|
||||
import * as READONLY from './READONLY';
|
||||
import * as READWRITE from './READWRITE';
|
||||
import * as RENAME from './RENAME';
|
||||
import * as RENAMENX from './RENAMENX';
|
||||
import * as REPLICAOF from './REPLICAOF';
|
||||
import * as RESTORE_ASKING from './RESTORE-ASKING';
|
||||
import * as ROLE from './ROLE';
|
||||
import * as RPOP_COUNT from './RPOP_COUNT';
|
||||
import * as RPOP from './RPOP';
|
||||
import * as RPOPLPUSH from './RPOPLPUSH';
|
||||
import * as RPUSH from './RPUSH';
|
||||
import * as RPUSHX from './RPUSHX';
|
||||
import * as SADD from './SADD';
|
||||
import * as SAVE from './SAVE';
|
||||
import * as SCAN from './SCAN';
|
||||
import * as SCARD from './SCARD';
|
||||
import * as SCRIPT_DEBUG from './SCRIPT_DEBUG';
|
||||
import * as SCRIPT_EXISTS from './SCRIPT_EXISTS';
|
||||
import * as SCRIPT_FLUSH from './SCRIPT_FLUSH';
|
||||
import * as SCRIPT_KILL from './SCRIPT_KILL';
|
||||
import * as SCRIPT_LOAD from './SCRIPT_LOAD';
|
||||
import * as SDIFF from './SDIFF';
|
||||
import * as SDIFFSTORE from './SDIFFSTORE';
|
||||
import * as SET from './SET';
|
||||
import * as SETBIT from './SETBIT';
|
||||
import * as SETEX from './SETEX';
|
||||
import * as SETNX from './SETNX';
|
||||
import * as SETRANGE from './SETRANGE';
|
||||
import * as SHUTDOWN from './SHUTDOWN';
|
||||
import * as SINTER from './SINTER';
|
||||
import * as SINTERSTORE from './SINTERSTORE';
|
||||
import * as SISMEMBER from './SISMEMBER';
|
||||
import * as SMEMBERS from './SMEMBERS';
|
||||
import * as SMISMEMBER from './SMISMEMBER';
|
||||
import * as SMOVE from './SMOVE';
|
||||
import * as SORT from './SORT';
|
||||
import * as SPOP from './SPOP';
|
||||
import * as SRANDMEMBER_COUNT from './SRANDMEMBER_COUNT';
|
||||
import * as SRANDMEMBER from './SRANDMEMBER';
|
||||
import * as SREM from './SREM';
|
||||
import * as SSCAN from './SSCAN';
|
||||
import * as STRLEN from './STRLEN';
|
||||
import * as SUNION from './SUNION';
|
||||
import * as SUNIONSTORE from './SUNIONSTORE';
|
||||
import * as SWAPDB from './SWAPDB';
|
||||
import * as TIME from './TIME';
|
||||
import * as TOUCH from './TOUCH';
|
||||
import * as TTL from './TTL';
|
||||
import * as TYPE from './TYPE';
|
||||
import * as UNLINK from './UNLINK';
|
||||
import * as UNWATCH from './UNWATCH';
|
||||
import * as WAIT from './WAIT';
|
||||
import * as WATCH from './WATCH';
|
||||
import * as XACK from './XACK';
|
||||
import * as XADD from './XADD';
|
||||
import * as XAUTOCLAIM_JUSTID from './XAUTOCLAIM_JUSTID';
|
||||
import * as XAUTOCLAIM from './XAUTOCLAIM';
|
||||
import * as XCLAIM from './XCLAIM';
|
||||
import * as XCLAIM_JUSTID from './XCLAIM_JUSTID';
|
||||
import * as XDEL from './XDEL';
|
||||
import * as XGROUP_CREATE from './XGROUP_CREATE';
|
||||
import * as XGROUP_CREATECONSUMER from './XGROUP_CREATECONSUMER';
|
||||
import * as XGROUP_DELCONSUMER from './XGROUP_DELCONSUMER';
|
||||
import * as XGROUP_DESTROY from './XGROUP_DESTROY';
|
||||
import * as XGROUP_SETID from './XGROUP_SETID';
|
||||
import * as XINFO_CONSUMERS from './XINFO_CONSUMERS';
|
||||
import * as XINFO_GROUPS from './XINFO_GROUPS';
|
||||
import * as XINFO_STREAM from './XINFO_STREAM';
|
||||
import * as XLEN from './XLEN';
|
||||
import * as XPENDING_RANGE from './XPENDING_RANGE';
|
||||
import * as XPENDING from './XPENDING';
|
||||
import * as XRANGE from './XRANGE';
|
||||
import * as XREAD from './XREAD';
|
||||
import * as XREADGROUP from './XREADGROUP';
|
||||
import * as XREVRANGE from './XREVRANGE';
|
||||
import * as XTRIM from './XTRIM';
|
||||
import * as ZADD from './ZADD';
|
||||
import * as ZCARD from './ZCARD';
|
||||
import * as ZCOUNT from './ZCOUNT';
|
||||
import * as ZDIFF_WITHSCORES from './ZDIFF_WITHSCORES';
|
||||
import * as ZDIFF from './ZDIFF';
|
||||
import * as ZDIFFSTORE from './ZDIFFSTORE';
|
||||
import * as ZINCRBY from './ZINCRBY';
|
||||
import * as ZINTER_WITHSCORES from './ZINTER_WITHSCORES';
|
||||
import * as ZINTER from './ZINTER';
|
||||
import * as ZINTERSTORE from './ZINTERSTORE';
|
||||
import * as ZLEXCOUNT from './ZLEXCOUNT';
|
||||
import * as ZMSCORE from './ZMSCORE';
|
||||
import * as ZPOPMAX_COUNT from './ZPOPMAX_COUNT';
|
||||
import * as ZPOPMAX from './ZPOPMAX';
|
||||
import * as ZPOPMIN_COUNT from './ZPOPMIN_COUNT';
|
||||
import * as ZPOPMIN from './ZPOPMIN';
|
||||
import * as ZRANDMEMBER_COUNT_WITHSCORES from './ZRANDMEMBER_COUNT_WITHSCORES';
|
||||
import * as ZRANDMEMBER_COUNT from './ZRANDMEMBER_COUNT';
|
||||
import * as ZRANDMEMBER from './ZRANDMEMBER';
|
||||
import * as ZRANGE_WITHSCORES from './ZRANGE_WITHSCORES';
|
||||
import * as ZRANGE from './ZRANGE';
|
||||
import * as ZRANGEBYLEX from './ZRANGEBYLEX';
|
||||
import * as ZRANGEBYSCORE_WITHSCORES from './ZRANGEBYSCORE_WITHSCORES';
|
||||
import * as ZRANGEBYSCORE from './ZRANGEBYSCORE';
|
||||
import * as ZRANGESTORE from './ZRANGESTORE';
|
||||
import * as ZRANK from './ZRANK';
|
||||
import * as ZREM from './ZREM';
|
||||
import * as ZREMRANGEBYLEX from './ZREMRANGEBYLEX';
|
||||
import * as ZREMRANGEBYRANK from './ZREMRANGEBYRANK';
|
||||
import * as ZREMRANGEBYSCORE from './ZREMRANGEBYSCORE';
|
||||
import * as ZREVRANK from './ZREVRANK';
|
||||
import * as ZSCAN from './ZSCAN';
|
||||
import * as ZSCORE from './ZSCORE';
|
||||
import * as ZUNION_WITHSCORES from './ZUNION_WITHSCORES';
|
||||
import * as ZUNION from './ZUNION';
|
||||
import * as ZUNIONSTORE from './ZUNIONSTORE';
|
||||
import { RedisScriptConfig, SHA1 } from '../lua-script';
|
||||
|
||||
export default {
|
||||
ACL_CAT,
|
||||
aclCat: ACL_CAT,
|
||||
ACL_DELUSER,
|
||||
aclDelUser: ACL_DELUSER,
|
||||
ACL_GENPASS,
|
||||
aclGenPass: ACL_GENPASS,
|
||||
ACL_GETUSER,
|
||||
aclGetUser: ACL_GETUSER,
|
||||
ACL_LIST,
|
||||
aclList: ACL_LIST,
|
||||
ACL_LOAD,
|
||||
aclLoad: ACL_LOAD,
|
||||
ACL_LOG_RESET,
|
||||
aclLogReset: ACL_LOG_RESET,
|
||||
ACL_LOG,
|
||||
aclLog: ACL_LOG,
|
||||
ACL_SAVE,
|
||||
aclSave: ACL_SAVE,
|
||||
ACL_SETUSER,
|
||||
aclSetUser: ACL_SETUSER,
|
||||
ACL_USERS,
|
||||
aclUsers: ACL_USERS,
|
||||
ACL_WHOAMI,
|
||||
aclWhoAmI: ACL_WHOAMI,
|
||||
APPEND,
|
||||
append: APPEND,
|
||||
ASKING,
|
||||
asking: ASKING,
|
||||
AUTH,
|
||||
auth: AUTH,
|
||||
BGREWRITEAOF,
|
||||
bgRewriteAof: BGREWRITEAOF,
|
||||
BGSAVE,
|
||||
bgSave: BGSAVE,
|
||||
BITCOUNT,
|
||||
bitCount: BITCOUNT,
|
||||
BITFIELD,
|
||||
bitField: BITFIELD,
|
||||
BITOP,
|
||||
bitOp: BITOP,
|
||||
BITPOS,
|
||||
bitPos: BITPOS,
|
||||
BLMOVE,
|
||||
blMove: BLMOVE,
|
||||
BLPOP,
|
||||
blPop: BLPOP,
|
||||
BRPOP,
|
||||
brPop: BRPOP,
|
||||
BRPOPLPUSH,
|
||||
brPopLPush: BRPOPLPUSH,
|
||||
BZPOPMAX,
|
||||
bzPopMax: BZPOPMAX,
|
||||
BZPOPMIN,
|
||||
bzPopMin: BZPOPMIN,
|
||||
CLIENT_ID,
|
||||
clientId: CLIENT_ID,
|
||||
CLIENT_INFO,
|
||||
clientInfo: CLIENT_INFO,
|
||||
CLUSTER_ADDSLOTS,
|
||||
clusterAddSlots: CLUSTER_ADDSLOTS,
|
||||
CLUSTER_FLUSHSLOTS,
|
||||
clusterFlushSlots: CLUSTER_FLUSHSLOTS,
|
||||
CLUSTER_INFO,
|
||||
clusterInfo: CLUSTER_INFO,
|
||||
CLUSTER_NODES,
|
||||
clusterNodes: CLUSTER_NODES,
|
||||
CLUSTER_MEET,
|
||||
clusterMeet: CLUSTER_MEET,
|
||||
CLUSTER_RESET,
|
||||
clusterReset: CLUSTER_RESET,
|
||||
CLUSTER_SETSLOT,
|
||||
clusterSetSlot: CLUSTER_SETSLOT,
|
||||
CLUSTER_SLOTS,
|
||||
clusterSlots: CLUSTER_SLOTS,
|
||||
COMMAND_COUNT,
|
||||
commandCount: COMMAND_COUNT,
|
||||
COMMAND_GETKEYS,
|
||||
commandGetKeys: COMMAND_GETKEYS,
|
||||
COMMAND_INFO,
|
||||
commandInfo: COMMAND_INFO,
|
||||
COMMAND,
|
||||
command: COMMAND,
|
||||
CONFIG_GET,
|
||||
configGet: CONFIG_GET,
|
||||
CONFIG_RESETASTAT,
|
||||
configResetStat: CONFIG_RESETASTAT,
|
||||
CONFIG_REWRITE,
|
||||
configRewrite: CONFIG_REWRITE,
|
||||
CONFIG_SET,
|
||||
configSet: CONFIG_SET,
|
||||
COPY,
|
||||
copy: COPY,
|
||||
DBSIZE,
|
||||
dbSize: DBSIZE,
|
||||
DECR,
|
||||
decr: DECR,
|
||||
DECRBY,
|
||||
decrBy: DECRBY,
|
||||
DEL,
|
||||
del: DEL,
|
||||
DISCARD,
|
||||
discard: DISCARD,
|
||||
DUMP,
|
||||
dump: DUMP,
|
||||
ECHO,
|
||||
echo: ECHO,
|
||||
EVAL,
|
||||
eval: EVAL,
|
||||
EVALSHA,
|
||||
evalSha: EVALSHA,
|
||||
EXISTS,
|
||||
exists: EXISTS,
|
||||
EXPIRE,
|
||||
expire: EXPIRE,
|
||||
EXPIREAT,
|
||||
expireAt: EXPIREAT,
|
||||
FAILOVER,
|
||||
failover: FAILOVER,
|
||||
FLUSHALL,
|
||||
flushAll: FLUSHALL,
|
||||
FLUSHDB,
|
||||
flushDb: FLUSHDB,
|
||||
GEOADD,
|
||||
geoAdd: GEOADD,
|
||||
GEODIST,
|
||||
geoDist: GEODIST,
|
||||
GEOHASH,
|
||||
geoHash: GEOHASH,
|
||||
GEOPOS,
|
||||
geoPos: GEOPOS,
|
||||
GEOSEARCH_WITH,
|
||||
geoSearchWith: GEOSEARCH_WITH,
|
||||
GEOSEARCH,
|
||||
geoSearch: GEOSEARCH,
|
||||
GEOSEARCHSTORE,
|
||||
geoSearchStore: GEOSEARCHSTORE,
|
||||
GET_BUFFER,
|
||||
getBuffer: GET_BUFFER,
|
||||
GET,
|
||||
get: GET,
|
||||
GETBIT,
|
||||
getBit: GETBIT,
|
||||
GETDEL,
|
||||
getDel: GETDEL,
|
||||
GETEX,
|
||||
getEx: GETEX,
|
||||
GETRANGE,
|
||||
getRange: GETRANGE,
|
||||
GETSET,
|
||||
getSet: GETSET,
|
||||
HDEL,
|
||||
hDel: HDEL,
|
||||
HELLO,
|
||||
hello: HELLO,
|
||||
HEXISTS,
|
||||
hExists: HEXISTS,
|
||||
HGET,
|
||||
hGet: HGET,
|
||||
HGETALL,
|
||||
hGetAll: HGETALL,
|
||||
HINCRBY,
|
||||
hIncrBy: HINCRBY,
|
||||
HINCRBYFLOAT,
|
||||
hIncrByFloat: HINCRBYFLOAT,
|
||||
HKEYS,
|
||||
hKeys: HKEYS,
|
||||
HLEN,
|
||||
hLen: HLEN,
|
||||
HMGET,
|
||||
hmGet: HMGET,
|
||||
HRANDFIELD_COUNT_WITHVALUES,
|
||||
hRandFieldCountWithValues: HRANDFIELD_COUNT_WITHVALUES,
|
||||
HRANDFIELD_COUNT,
|
||||
hRandFieldCount: HRANDFIELD_COUNT,
|
||||
HRANDFIELD,
|
||||
hRandField: HRANDFIELD,
|
||||
HSCAN,
|
||||
hScan: HSCAN,
|
||||
HSET,
|
||||
hSet: HSET,
|
||||
HSETNX,
|
||||
hSetNX: HSETNX,
|
||||
HSTRLEN,
|
||||
hStrLen: HSTRLEN,
|
||||
HVALS,
|
||||
hVals: HVALS,
|
||||
INCR,
|
||||
incr: INCR,
|
||||
INCRBY,
|
||||
incrBy: INCRBY,
|
||||
INCRBYFLOAT,
|
||||
incrByFloat: INCRBYFLOAT,
|
||||
INFO,
|
||||
info: INFO,
|
||||
KEYS,
|
||||
keys: KEYS,
|
||||
LASTSAVE,
|
||||
lastSave: LASTSAVE,
|
||||
LINDEX,
|
||||
lIndex: LINDEX,
|
||||
LINSERT,
|
||||
lInsert: LINSERT,
|
||||
LLEN,
|
||||
lLen: LLEN,
|
||||
LMOVE,
|
||||
lMove: LMOVE,
|
||||
LOLWUT,
|
||||
LPOP_COUNT,
|
||||
lPopCount: LPOP_COUNT,
|
||||
LPOP,
|
||||
lPop: LPOP,
|
||||
LPOS_COUNT,
|
||||
lPosCount: LPOS_COUNT,
|
||||
LPOS,
|
||||
lPos: LPOS,
|
||||
LPUSH,
|
||||
lPush: LPUSH,
|
||||
LPUSHX,
|
||||
lPushX: LPUSHX,
|
||||
LRANGE,
|
||||
lRange: LRANGE,
|
||||
LREM,
|
||||
lRem: LREM,
|
||||
LSET,
|
||||
lSet: LSET,
|
||||
LTRIM,
|
||||
lTrim: LTRIM,
|
||||
MEMOERY_DOCTOR,
|
||||
memoryDoctor: MEMOERY_DOCTOR,
|
||||
'MEMORY_MALLOC-STATS': MEMORY_MALLOC_STATS,
|
||||
memoryMallocStats: MEMORY_MALLOC_STATS,
|
||||
MEMORY_PURGE,
|
||||
memoryPurge: MEMORY_PURGE,
|
||||
MEMORY_STATS,
|
||||
memoryStats: MEMORY_STATS,
|
||||
MEMORY_USAGE,
|
||||
memoryUsage: MEMORY_USAGE,
|
||||
MGET,
|
||||
mGet: MGET,
|
||||
MIGRATE,
|
||||
migrate: MIGRATE,
|
||||
MODULE_LIST,
|
||||
moduleList: MODULE_LIST,
|
||||
MODULE_LOAD,
|
||||
moduleLoad: MODULE_LOAD,
|
||||
MODULE_UNLOAD,
|
||||
moduleUnload: MODULE_UNLOAD,
|
||||
MOVE,
|
||||
move: MOVE,
|
||||
MSET,
|
||||
mSet: MSET,
|
||||
MSETNX,
|
||||
mSetNX: MSETNX,
|
||||
PERSIST,
|
||||
persist: PERSIST,
|
||||
PEXPIRE,
|
||||
pExpire: PEXPIRE,
|
||||
PEXPIREAT,
|
||||
pExpireAt: PEXPIREAT,
|
||||
PFADD,
|
||||
pfAdd: PFADD,
|
||||
PFCOUNT,
|
||||
pfCount: PFCOUNT,
|
||||
PFMERGE,
|
||||
pfMerge: PFMERGE,
|
||||
PING,
|
||||
ping: PING,
|
||||
PSETEX,
|
||||
pSetEx: PSETEX,
|
||||
PTTL,
|
||||
pTTL: PTTL,
|
||||
PUBLISH,
|
||||
publish: PUBLISH,
|
||||
PUBSUB_CHANNELS,
|
||||
pubSubChannels: PUBSUB_CHANNELS,
|
||||
PUBSUB_NUMPAT,
|
||||
pubSubNumPat: PUBSUB_NUMPAT,
|
||||
PUBSUB_NUMSUB,
|
||||
pubSubNumSub: PUBSUB_NUMSUB,
|
||||
RANDOMKEY,
|
||||
randomKey: RANDOMKEY,
|
||||
READONLY,
|
||||
readonly: READONLY,
|
||||
READWRITE,
|
||||
readwrite: READWRITE,
|
||||
RENAME,
|
||||
rename: RENAME,
|
||||
RENAMENX,
|
||||
renameNX: RENAMENX,
|
||||
REPLICAOF,
|
||||
replicaOf: REPLICAOF,
|
||||
'RESTORE-ASKING': RESTORE_ASKING,
|
||||
restoreAsking: RESTORE_ASKING,
|
||||
ROLE,
|
||||
role: ROLE,
|
||||
RPOP_COUNT,
|
||||
rPopCount: RPOP_COUNT,
|
||||
RPOP,
|
||||
rPop: RPOP,
|
||||
RPOPLPUSH,
|
||||
rPopLPush: RPOPLPUSH,
|
||||
RPUSH,
|
||||
rPush: RPUSH,
|
||||
RPUSHX,
|
||||
rPushX: RPUSHX,
|
||||
SADD,
|
||||
sAdd: SADD,
|
||||
SAVE,
|
||||
save: SAVE,
|
||||
SCAN,
|
||||
scan: SCAN,
|
||||
SCARD,
|
||||
sCard: SCARD,
|
||||
SCRIPT_DEBUG,
|
||||
scriptDebug: SCRIPT_DEBUG,
|
||||
SCRIPT_EXISTS,
|
||||
scriptExists: SCRIPT_EXISTS,
|
||||
SCRIPT_FLUSH,
|
||||
scriptFlush: SCRIPT_FLUSH,
|
||||
SCRIPT_KILL,
|
||||
scriptKill: SCRIPT_KILL,
|
||||
SCRIPT_LOAD,
|
||||
scriptLoad: SCRIPT_LOAD,
|
||||
SDIFF,
|
||||
sDiff: SDIFF,
|
||||
SDIFFSTORE,
|
||||
sDiffStore: SDIFFSTORE,
|
||||
SINTER,
|
||||
sInter: SINTER,
|
||||
SINTERSTORE,
|
||||
sInterStore: SINTERSTORE,
|
||||
SET,
|
||||
set: SET,
|
||||
SETBIT,
|
||||
setBit: SETBIT,
|
||||
SETEX,
|
||||
setEx: SETEX,
|
||||
SETNX,
|
||||
setNX: SETNX,
|
||||
SETRANGE,
|
||||
setRange: SETRANGE,
|
||||
SHUTDOWN,
|
||||
shutdown: SHUTDOWN,
|
||||
SISMEMBER,
|
||||
sIsMember: SISMEMBER,
|
||||
SMEMBERS,
|
||||
sMembers: SMEMBERS,
|
||||
SMISMEMBER,
|
||||
smIsMember: SMISMEMBER,
|
||||
SMOVE,
|
||||
sMove: SMOVE,
|
||||
SORT,
|
||||
sort: SORT,
|
||||
SPOP,
|
||||
sPop: SPOP,
|
||||
SRANDMEMBER_COUNT,
|
||||
sRandMemberCount: SRANDMEMBER_COUNT,
|
||||
SRANDMEMBER,
|
||||
sRandMember: SRANDMEMBER,
|
||||
SREM,
|
||||
sRem: SREM,
|
||||
SSCAN,
|
||||
sScan: SSCAN,
|
||||
STRLEN,
|
||||
strLen: STRLEN,
|
||||
SUNION,
|
||||
sUnion: SUNION,
|
||||
SUNIONSTORE,
|
||||
sUnionStore: SUNIONSTORE,
|
||||
SWAPDB,
|
||||
swapDb: SWAPDB,
|
||||
TIME,
|
||||
time: TIME,
|
||||
TOUCH,
|
||||
touch: TOUCH,
|
||||
TTL,
|
||||
ttl: TTL,
|
||||
TYPE,
|
||||
type: TYPE,
|
||||
UNLINK,
|
||||
unlink: UNLINK,
|
||||
UNWATCH,
|
||||
unwatch: UNWATCH,
|
||||
WAIT,
|
||||
wait: WAIT,
|
||||
WATCH,
|
||||
watch: WATCH,
|
||||
XACK,
|
||||
xAck: XACK,
|
||||
XADD,
|
||||
xAdd: XADD,
|
||||
XAUTOCLAIM_JUSTID,
|
||||
xAutoClaimJustId: XAUTOCLAIM_JUSTID,
|
||||
XAUTOCLAIM,
|
||||
xAutoClaim: XAUTOCLAIM,
|
||||
XCLAIM,
|
||||
xClaim: XCLAIM,
|
||||
XCLAIM_JUSTID,
|
||||
xClaimJustId: XCLAIM_JUSTID,
|
||||
XDEL,
|
||||
xDel: XDEL,
|
||||
XGROUP_CREATE,
|
||||
xGroupCreate: XGROUP_CREATE,
|
||||
XGROUP_CREATECONSUMER,
|
||||
xGroupCreateConsumer: XGROUP_CREATECONSUMER,
|
||||
XGROUP_DELCONSUMER,
|
||||
xGroupDelConsumer: XGROUP_DELCONSUMER,
|
||||
XGROUP_DESTROY,
|
||||
xGroupDestroy: XGROUP_DESTROY,
|
||||
XGROUP_SETID,
|
||||
xGroupSetId: XGROUP_SETID,
|
||||
XINFO_CONSUMERS,
|
||||
xInfoConsumers: XINFO_CONSUMERS,
|
||||
XINFO_GROUPS,
|
||||
xInfoGroups: XINFO_GROUPS,
|
||||
XINFO_STREAM,
|
||||
xInfoStream: XINFO_STREAM,
|
||||
XLEN,
|
||||
xLen: XLEN,
|
||||
XPENDING_RANGE,
|
||||
xPendingRange: XPENDING_RANGE,
|
||||
XPENDING,
|
||||
xPending: XPENDING,
|
||||
XRANGE,
|
||||
xRange: XRANGE,
|
||||
XREAD,
|
||||
xRead: XREAD,
|
||||
XREADGROUP,
|
||||
xReadGroup: XREADGROUP,
|
||||
XREVRANGE,
|
||||
xRevRange: XREVRANGE,
|
||||
XTRIM,
|
||||
xTrim: XTRIM,
|
||||
ZADD,
|
||||
zAdd: ZADD,
|
||||
ZCARD,
|
||||
zCard: ZCARD,
|
||||
ZCOUNT,
|
||||
zCount: ZCOUNT,
|
||||
ZDIFF_WITHSCORES,
|
||||
zDiffWithScores: ZDIFF_WITHSCORES,
|
||||
ZDIFF,
|
||||
zDiff: ZDIFF,
|
||||
ZDIFFSTORE,
|
||||
zDiffStore: ZDIFFSTORE,
|
||||
ZINCRBY,
|
||||
zIncrBy: ZINCRBY,
|
||||
ZINTER_WITHSCORES,
|
||||
zInterWithScores: ZINTER_WITHSCORES,
|
||||
ZINTER,
|
||||
zInter: ZINTER,
|
||||
ZINTERSTORE,
|
||||
zInterStore: ZINTERSTORE,
|
||||
ZLEXCOUNT,
|
||||
zLexCount: ZLEXCOUNT,
|
||||
ZMSCORE,
|
||||
zmScore: ZMSCORE,
|
||||
ZPOPMAX_COUNT,
|
||||
zPopMaxCount: ZPOPMAX_COUNT,
|
||||
ZPOPMAX,
|
||||
zPopMax: ZPOPMAX,
|
||||
ZPOPMIN_COUNT,
|
||||
zPopMinCount: ZPOPMIN_COUNT,
|
||||
ZPOPMIN,
|
||||
zPopMin: ZPOPMIN,
|
||||
ZRANDMEMBER_COUNT_WITHSCORES,
|
||||
zRandMemberCountWithScores: ZRANDMEMBER_COUNT_WITHSCORES,
|
||||
ZRANDMEMBER_COUNT,
|
||||
zRandMemberCount: ZRANDMEMBER_COUNT,
|
||||
ZRANDMEMBER,
|
||||
zRandMember: ZRANDMEMBER,
|
||||
ZRANGE_WITHSCORES,
|
||||
zRangeWithScores: ZRANGE_WITHSCORES,
|
||||
ZRANGE,
|
||||
zRange: ZRANGE,
|
||||
ZRANGEBYLEX,
|
||||
zRangeByLex: ZRANGEBYLEX,
|
||||
ZRANGEBYSCORE_WITHSCORES,
|
||||
zRangeByScoreWithScores: ZRANGEBYSCORE_WITHSCORES,
|
||||
ZRANGEBYSCORE,
|
||||
zRangeByScore: ZRANGEBYSCORE,
|
||||
ZRANGESTORE,
|
||||
zRangeStore: ZRANGESTORE,
|
||||
ZRANK,
|
||||
zRank: ZRANK,
|
||||
ZREM,
|
||||
zRem: ZREM,
|
||||
ZREMRANGEBYLEX,
|
||||
zRemRangeByLex: ZREMRANGEBYLEX,
|
||||
ZREMRANGEBYRANK,
|
||||
zRemRangeByRank: ZREMRANGEBYRANK,
|
||||
ZREMRANGEBYSCORE,
|
||||
zRemRangeByScore: ZREMRANGEBYSCORE,
|
||||
ZREVRANK,
|
||||
zRevRank: ZREVRANK,
|
||||
ZSCAN,
|
||||
zScan: ZSCAN,
|
||||
ZSCORE,
|
||||
zScore: ZSCORE,
|
||||
ZUNION_WITHSCORES,
|
||||
zUnionWithScores: ZUNION_WITHSCORES,
|
||||
ZUNION,
|
||||
zUnion: ZUNION,
|
||||
ZUNIONSTORE,
|
||||
zUnionStore: ZUNIONSTORE
|
||||
};
|
||||
export type RedisCommandRawReply = string | number | Buffer | Array<RedisCommandRawReply> | null | undefined;
|
||||
|
||||
export type RedisReply = string | number | Buffer | Array<RedisReply> | null | undefined;
|
||||
|
||||
export type TransformArgumentsReply = Array<string | Buffer> & { preserve?: unknown };
|
||||
export type RedisCommandArguments = Array<string | Buffer> & { preserve?: unknown };
|
||||
|
||||
export interface RedisCommand {
|
||||
FIRST_KEY_INDEX?: number | ((...args: Array<any>) => string);
|
||||
IS_READ_ONLY?: boolean;
|
||||
transformArguments(this: void, ...args: Array<any>): TransformArgumentsReply;
|
||||
transformArguments(this: void, ...args: Array<any>): RedisCommandArguments;
|
||||
BUFFER_MODE?: boolean;
|
||||
transformReply?(this: void, reply: RedisReply, preserved?: unknown): any;
|
||||
transformReply?(this: void, reply: RedisCommandRawReply, preserved?: unknown): any;
|
||||
}
|
||||
|
||||
export type RedisCommandReply<C extends RedisCommand> = C['transformReply'] extends (...args: any) => infer T ? T : RedisReply;
|
||||
export type RedisCommandReply<C extends RedisCommand> = C['transformReply'] extends (...args: any) => infer T ? T : RedisCommandRawReply;
|
||||
|
||||
export interface RedisCommands {
|
||||
[command: string]: RedisCommand;
|
||||
@ -785,4 +25,14 @@ export interface RedisModule {
|
||||
export interface RedisModules {
|
||||
[module: string]: RedisModule;
|
||||
}
|
||||
// export type RedisModules = Record<string, RedisModule>;
|
||||
|
||||
export type RedisScript = RedisScriptConfig & SHA1;
|
||||
|
||||
export interface RedisScripts {
|
||||
[script: string]: RedisScript;
|
||||
}
|
||||
|
||||
export interface RedisPlugins<M extends RedisModules, S extends RedisScripts> {
|
||||
modules?: M;
|
||||
scripts?: S;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { createHash } from 'crypto';
|
||||
import { RedisCommand } from './commands';
|
||||
|
||||
export interface RedisLuaScriptConfig extends RedisCommand {
|
||||
export interface RedisScriptConfig extends RedisCommand {
|
||||
SCRIPT: string;
|
||||
NUMBER_OF_KEYS: number;
|
||||
}
|
||||
@ -10,13 +10,7 @@ export interface SHA1 {
|
||||
SHA1: string;
|
||||
}
|
||||
|
||||
export type RedisLuaScript = RedisLuaScriptConfig & SHA1;
|
||||
|
||||
export interface RedisLuaScripts {
|
||||
[script: string]: RedisLuaScript;
|
||||
}
|
||||
|
||||
export function defineScript(script: RedisLuaScriptConfig): typeof script & SHA1 {
|
||||
export function defineScript(script: RedisScriptConfig): typeof script & SHA1 {
|
||||
return {
|
||||
...script,
|
||||
SHA1: scriptSha1(script.SCRIPT)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user