Skip to content

Commit 0f15dc2

Browse files
author
Ruben Bridgewater
committed
Add MIGRATE [...] KEYS key1, ... support
1 parent 9b0ba69 commit 0f15dc2

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Features
44

5+
- Added support for `MIGRATE [...] KEYS key1, key2` (Redis >= v.3.0.6)
56
- Added build sanity check for unhandled commands with moveable keys
67
- Rebuild the commands with the newest unstable release
78

index.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ exports.getKeyIndexes = function (commandName, args, options) {
7373
throw new Error('Expect args to be an array');
7474
}
7575

76-
var parseExternalKey = options && options.parseExternalKey;
77-
7876
var keys = [];
79-
var i, range, keyStart, keyStop;
77+
var i, keyStart, keyStop, parseExternalKey;
8078
switch (commandName) {
79+
case 'zunionstore':
80+
case 'zinterstore':
81+
keys.push(0);
8182
case 'eval':
8283
case 'evalsha':
8384
keyStop = Number(args[1]) + 2;
@@ -86,6 +87,7 @@ exports.getKeyIndexes = function (commandName, args, options) {
8687
}
8788
break;
8889
case 'sort':
90+
parseExternalKey = options && options.parseExternalKey;
8991
keys.push(0);
9092
for (i = 1; i < args.length - 1; i++) {
9193
if (typeof args[i] !== 'string') {
@@ -114,12 +116,18 @@ exports.getKeyIndexes = function (commandName, args, options) {
114116
}
115117
}
116118
break;
117-
case 'zunionstore':
118-
case 'zinterstore':
119-
keys.push(0);
120-
keyStop = Number(args[1]) + 2;
121-
for (i = 2; i < keyStop; i++) {
122-
keys.push(i);
119+
case 'migrate':
120+
if (args[2] === '') {
121+
for (i = 5; i < args.length - 1; i++) {
122+
if (args[i].toUpperCase() === 'KEYS') {
123+
for (var j = i + 1; j < args.length; j++) {
124+
keys.push(j);
125+
}
126+
break;
127+
}
128+
}
129+
} else {
130+
keys.push(2);
123131
}
124132
break;
125133
default:

0 commit comments

Comments
 (0)