diff --git a/commands.json b/commands.json index 140517b..5552f8c 100644 --- a/commands.json +++ b/commands.json @@ -33,7 +33,8 @@ "bgrewriteaof": { "arity": 1, "flags": [ - "admin" + "admin", + "noscript" ], "keyStart": 0, "keyStop": 0, @@ -42,7 +43,8 @@ "bgsave": { "arity": -1, "flags": [ - "admin" + "admin", + "noscript" ], "keyStart": 0, "keyStop": 0, @@ -161,6 +163,7 @@ "command": { "arity": 1, "flags": [ + "random", "loading", "stale" ], @@ -172,6 +175,7 @@ "arity": -2, "flags": [ "admin", + "noscript", "loading", "stale" ], @@ -243,7 +247,8 @@ "dump": { "arity": 2, "flags": [ - "readonly" + "readonly", + "random" ], "keyStart": 1, "keyStop": 1, @@ -485,7 +490,8 @@ "hgetall": { "arity": 2, "flags": [ - "readonly" + "readonly", + "random" ], "keyStart": 1, "keyStop": 1, @@ -652,6 +658,7 @@ "info": { "arity": -1, "flags": [ + "random", "loading", "stale" ], @@ -720,6 +727,15 @@ "keyStop": 1, "step": 1 }, + "lolwut": { + "arity": -1, + "flags": [ + "readonly" + ], + "keyStart": 0, + "keyStop": 0, + "step": 0 + }, "lpop": { "arity": 2, "flags": [ @@ -792,7 +808,8 @@ "memory": { "arity": -2, "flags": [ - "readonly" + "readonly", + "random" ], "keyStart": 0, "keyStop": 0, @@ -812,6 +829,7 @@ "arity": -6, "flags": [ "write", + "random", "movablekeys" ], "keyStart": 0, @@ -881,7 +899,8 @@ "object": { "arity": -2, "flags": [ - "readonly" + "readonly", + "random" ], "keyStart": 2, "keyStop": 2, @@ -1022,6 +1041,7 @@ "arity": 2, "flags": [ "readonly", + "random", "fast" ], "keyStart": 1, @@ -1134,6 +1154,17 @@ "keyStop": 0, "step": 0 }, + "replicaof": { + "arity": 3, + "flags": [ + "admin", + "noscript", + "stale" + ], + "keyStart": 0, + "keyStop": 0, + "step": 0 + }, "restore": { "arity": -4, "flags": [ @@ -1343,6 +1374,7 @@ "arity": -1, "flags": [ "admin", + "noscript", "loading", "stale" ], @@ -1394,7 +1426,8 @@ "slowlog": { "arity": -2, "flags": [ - "admin" + "admin", + "random" ], "keyStart": 0, "keyStop": 0, @@ -1568,6 +1601,7 @@ "arity": 2, "flags": [ "readonly", + "random", "fast" ], "keyStart": 1, @@ -1636,7 +1670,7 @@ "step": 1 }, "xack": { - "arity": -3, + "arity": -4, "flags": [ "write", "fast" @@ -1650,6 +1684,7 @@ "flags": [ "write", "denyoom", + "random", "fast" ], "keyStart": 1, @@ -1657,9 +1692,10 @@ "step": 1 }, "xclaim": { - "arity": -5, + "arity": -6, "flags": [ "write", + "random", "fast" ], "keyStart": 1, @@ -1667,7 +1703,7 @@ "step": 1 }, "xdel": { - "arity": -2, + "arity": -3, "flags": [ "write", "fast" @@ -1689,7 +1725,8 @@ "xinfo": { "arity": -2, "flags": [ - "readonly" + "readonly", + "random" ], "keyStart": 2, "keyStop": 2, @@ -1708,7 +1745,8 @@ "xpending": { "arity": -3, "flags": [ - "readonly" + "readonly", + "random" ], "keyStart": 1, "keyStop": 1, @@ -1724,7 +1762,7 @@ "step": 1 }, "xread": { - "arity": -3, + "arity": -4, "flags": [ "readonly", "noscript", @@ -1735,7 +1773,7 @@ "step": 1 }, "xreadgroup": { - "arity": -3, + "arity": -7, "flags": [ "write", "noscript", @@ -1754,10 +1792,22 @@ "keyStop": 1, "step": 1 }, + "xsetid": { + "arity": 3, + "flags": [ + "write", + "denyoom", + "fast" + ], + "keyStart": 1, + "keyStop": 1, + "step": 1 + }, "xtrim": { "arity": -2, "flags": [ "write", + "random", "fast" ], "keyStart": 1, @@ -1834,7 +1884,7 @@ "fast" ], "keyStart": 1, - "keyStop": -1, + "keyStop": 1, "step": 1 }, "zpopmin": { @@ -1844,7 +1894,7 @@ "fast" ], "keyStart": 1, - "keyStop": -1, + "keyStop": 1, "step": 1 }, "zrange": { diff --git a/index.js b/index.js index 8b58437..60c157e 100644 --- a/index.js +++ b/index.js @@ -131,6 +131,19 @@ exports.getKeyIndexes = function (commandName, args, options) { keys.push(2) } break + case 'xreadgroup': + case 'xread': + // keys are 1st half of the args after STREAMS argument + for (i = commandName === 'xread' ? 0 : 3; i < args.length - 1; i++) { + if (String(args[i]).toUpperCase() === 'STREAMS') { + + for (j = i + 1; j <= i + ((args.length - 1 - i) / 2); j++) { + keys.push(j) + } + break + } + } + break default: // step has to be at least one in this case, otherwise the command does not contain a key if (command.step > 0) { diff --git a/test/index.js b/test/index.js index 8d557a4..41f7a7a 100644 --- a/test/index.js +++ b/test/index.js @@ -92,6 +92,14 @@ describe('redis-commands', function () { expect(index('migrate', ['127.0.0.1', 6379, 'foo', 0, 0, 'COPY'])).to.eql([2]) expect(index('migrate', ['127.0.0.1', 6379, '', 0, 0, 'REPLACE', 'KEYS', 'foo', 'bar'])).to.eql([7, 8]) expect(index('migrate', ['127.0.0.1', 6379, '', 0, 0, 'KEYS', 'foo', 'bar'])).to.eql([6, 7]) + expect(index('xreadgroup', ['GROUP', 'group', 'consumer', 'COUNT', 10, 'BLOCK', 2000, 'NOACK', 'STREAMS', 'key1', 'key2', 'id1', 'id2'])).to.eql([9, 10]) + expect(index('xreadgroup', ['GROUP', 'group', 'consumer', 'STREAMS', 'key1', 'id1'])).to.eql([4]) + expect(index('xreadgroup', ['GROUP', 'group', 'consumer', 'STREAMS', 'key1', 'key2', 'id1', 'id2'])).to.eql([4, 5]) + expect(index('xreadgroup', ['GROUP', 'group', 'consumer', 'STREAMS', 'key1', 'key2', 'key3', 'id1', 'id2', 'id3'])).to.eql([4, 5, 6]) + expect(index('xread', ['COUNT', 10, 'BLOCK', 2000, 'STREAMS', 'key1', 'key2', 'id1', 'id2'])).to.eql([5, 6]) + expect(index('xread', ['STREAMS', 'key1', 'id1'])).to.eql([1]) + expect(index('xread', ['STREAMS', 'key1', 'key2', 'id1', 'id2'])).to.eql([1, 2]) + expect(index('xread', ['STREAMS', 'key1', 'key2', 'key3', 'id1', 'id2', 'id3'])).to.eql([1, 2, 3]) }) it('should support numeric argument', function () {