diff --git a/index.js b/index.js index 5397e94..a01073d 100644 --- a/index.js +++ b/index.js @@ -624,14 +624,14 @@ RedisClient.prototype.return_reply = function (reply) { if (command_obj && !command_obj.sub_command) { if (typeof command_obj.callback === "function") { - if (this.options.detect_buffers && command_obj.buffer_args === false && 'exec' !== command_obj.command.toLowerCase()) { + if (this.options.detect_buffers && command_obj.buffer_args === false && 'exec' !== command_obj.command) { // If detect_buffers option was specified, then the reply from the parser will be Buffers. // If this command did not use Buffer arguments, then convert the reply to Strings here. reply = reply_to_strings(reply); } // TODO - confusing and error-prone that hgetall is special cased in two places - if (reply && 'hgetall' === command_obj.command.toLowerCase()) { + if (reply && 'hgetall' === command_obj.command) { reply = reply_to_object(reply); } @@ -730,8 +730,7 @@ RedisClient.prototype.send_command = function (command, args, callback) { // client.sadd(arg1, [arg2, arg3, arg4], cb); // converts to: // client.sadd(arg1, arg2, arg3, arg4, cb); - lcaseCommand = command.toLowerCase(); - if ((lcaseCommand === 'sadd' || lcaseCommand === 'srem') && args.length > 0 && Array.isArray(args[args.length - 1])) { + if ((command === 'sadd' || command === 'srem') && args.length > 0 && Array.isArray(args[args.length - 1])) { args = args.slice(0, -1).concat(args[args.length - 1]); } @@ -885,7 +884,7 @@ RedisClient.prototype.end = function () { function Multi(client, args) { this._client = client; - this.queue = [["MULTI"]]; + this.queue = [["multi"]]; if (Array.isArray(args)) { this.queue = this.queue.concat(args); } @@ -1061,7 +1060,7 @@ Multi.prototype.exec = function (callback) { if (args.length === 1 && Array.isArray(args[0])) { args = args[0]; } - if (command.toLowerCase() === 'hmset' && typeof args[1] === 'object') { + if (command === 'hmset' && typeof args[1] === 'object') { obj = args.pop(); Object.keys(obj).forEach(function (key) { args.push(key); @@ -1081,7 +1080,7 @@ Multi.prototype.exec = function (callback) { }, this); // TODO - make this callback part of Multi.prototype instead of creating it each time - return this._client.send_command("EXEC", [], function (err, replies) { + return this._client.send_command("exec", [], function (err, replies) { if (err) { if (callback) { errors.push(new Error(err)); @@ -1106,7 +1105,7 @@ Multi.prototype.exec = function (callback) { } // TODO - confusing and error-prone that hgetall is special cased in two places - if (reply && args[0].toLowerCase() === "hgetall") { + if (reply && args[0] === "hgetall") { replies[i - 1] = reply = reply_to_object(reply); } diff --git a/test/commands/client.spec.js b/test/commands/client.spec.js index 50d0f48..31bb5dc 100644 --- a/test/commands/client.spec.js +++ b/test/commands/client.spec.js @@ -32,7 +32,7 @@ describe("The 'client' method", function () { describe('list', function () { it('lists connected clients', function (done) { - client.client("list", helper.match(pattern, done)); + client.client("LIST", helper.match(pattern, done)); }); it("lists connected clients when invoked with multi's chaining syntax", function (done) { diff --git a/test/commands/dbsize.spec.js b/test/commands/dbsize.spec.js index 5eb6958..118ba0b 100644 --- a/test/commands/dbsize.spec.js +++ b/test/commands/dbsize.spec.js @@ -59,7 +59,7 @@ describe("The 'dbsize' method", function () { }); it("returns a zero db size", function (done) { - client.dbsize([], function (err, res) { + client.DBSIZE([], function (err, res) { helper.isNotError()(err, res); helper.isType.number()(err, res); assert.strictEqual(res, 0, "Initial db size should be 0"); diff --git a/test/commands/del.spec.js b/test/commands/del.spec.js index 8a11048..152e9c1 100644 --- a/test/commands/del.spec.js +++ b/test/commands/del.spec.js @@ -21,7 +21,7 @@ describe("The 'del' method", function () { it('allows a single key to be deleted', function (done) { client.set('foo', 'bar'); - client.del('foo', helper.isNumber(1)); + client.DEL('foo', helper.isNumber(1)); client.get('foo', helper.isNull(done)); }); diff --git a/test/commands/eval.spec.js b/test/commands/eval.spec.js index 0c3edb0..f5b4694 100644 --- a/test/commands/eval.spec.js +++ b/test/commands/eval.spec.js @@ -35,7 +35,7 @@ describe("The 'eval' method", function () { }); it('returns a string', function (done) { - client.eval("return 'hello world'", 0, helper.isString('hello world', done)); + client.EVAL("return 'hello world'", 0, helper.isString('hello world', done)); }); it('converts boolean true to integer 1', function (done) { diff --git a/test/commands/exits.spec.js b/test/commands/exits.spec.js index 2fd2ac5..3e70742 100644 --- a/test/commands/exits.spec.js +++ b/test/commands/exits.spec.js @@ -21,7 +21,7 @@ describe("The 'exits' method", function () { it('returns 1 if the key exists', function (done) { client.set('foo', 'bar'); - client.exists('foo', helper.isNumber(1, done)); + client.EXISTS('foo', helper.isNumber(1, done)); }); it('returns 0 if the key does not exist', function (done) { diff --git a/test/commands/flushdb.spec.js b/test/commands/flushdb.spec.js index c8e70bf..0bc2336 100644 --- a/test/commands/flushdb.spec.js +++ b/test/commands/flushdb.spec.js @@ -76,7 +76,7 @@ describe("The 'flushdb' method", function () { return done(err); } - client.flushdb(function (err, res) { + client.FLUSHDB(function (err, res) { helper.isString("OK")(err, res); done(err); }); diff --git a/test/commands/get.spec.js b/test/commands/get.spec.js index 3d3fd1e..6defc2c 100644 --- a/test/commands/get.spec.js +++ b/test/commands/get.spec.js @@ -64,7 +64,7 @@ describe("The 'get' method", function () { }); it("gets the value correctly", function (done) { - client.get(key, function (err, res) { + client.GET(key, function (err, res) { helper.isString(value)(err, res); done(err); }); diff --git a/test/commands/getset.spec.js b/test/commands/getset.spec.js index a47cd2d..32b178b 100644 --- a/test/commands/getset.spec.js +++ b/test/commands/getset.spec.js @@ -65,7 +65,7 @@ describe("The 'getset' method", function () { }); it("gets the value correctly", function (done) { - client.getset(key, value2, function (err, res) { + client.GETSET(key, value2, function (err, res) { helper.isString(value)(err, res); client.get(key, function (err, res) { helper.isString(value2)(err, res); diff --git a/test/commands/hgetall.spec.js b/test/commands/hgetall.spec.js index 0735bf3..74b506e 100644 --- a/test/commands/hgetall.spec.js +++ b/test/commands/hgetall.spec.js @@ -35,7 +35,7 @@ describe("The 'hgetall' method", function () { }); it('handles fetching keys set using an object', function (done) { - client.hmset("msg_test", {message: "hello"}, helper.isString("OK")); + client.HMSET("msg_test", {message: "hello"}, helper.isString("OK")); client.hgetall("msg_test", function (err, obj) { assert.strictEqual(1, Object.keys(obj).length); assert.strictEqual(obj.message, "hello"); diff --git a/test/commands/hincrby.spec.js b/test/commands/hincrby.spec.js index c8a7cfc..7d55f11 100644 --- a/test/commands/hincrby.spec.js +++ b/test/commands/hincrby.spec.js @@ -24,7 +24,7 @@ describe("The 'hincrby' method", function () { var field = "field 1"; client.HSET(hash, field, 33); - client.HINCRBY(hash, field, 10, helper.isNumber(43, done)); + client.hincrby(hash, field, 10, helper.isNumber(43, done)); }); it('increments a key that has not been set', function (done) { diff --git a/test/commands/hmget.spec.js b/test/commands/hmget.spec.js index af673bf..5f7bc32 100644 --- a/test/commands/hmget.spec.js +++ b/test/commands/hmget.spec.js @@ -23,7 +23,7 @@ describe("The 'hmget' method", function () { }); it('allows keys to be specified using multiple arguments', function (done) { - client.HMGET(hash, "0123456789", "some manner of key", function (err, reply) { + client.hmget(hash, "0123456789", "some manner of key", function (err, reply) { assert.strictEqual("abcdefghij", reply[0].toString()); assert.strictEqual("a type of value", reply[1].toString()); return done(err); diff --git a/test/commands/hmset.spec.js b/test/commands/hmset.spec.js index 859f0c2..d5cc11e 100644 --- a/test/commands/hmset.spec.js +++ b/test/commands/hmset.spec.js @@ -31,7 +31,7 @@ describe("The 'hmset' method", function () { }); it('handles object-style syntax', function (done) { - client.HMSET(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value", "otherTypes": 555}, helper.isString('OK')); + client.hmset(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value", "otherTypes": 555}, helper.isString('OK')); client.HGETALL(hash, function (err, obj) { assert.equal(obj['0123456789'], 'abcdefghij'); assert.equal(obj['some manner of key'], 'a type of value'); diff --git a/test/commands/hset.spec.js b/test/commands/hset.spec.js index 7155e32..0424a97 100644 --- a/test/commands/hset.spec.js +++ b/test/commands/hset.spec.js @@ -25,7 +25,7 @@ describe("The 'hset' method", function () { var field = new Buffer("0123456789"); var value = new Buffer("abcdefghij"); - client.HSET(hash, field, value, helper.isNumber(1)); + client.hset(hash, field, value, helper.isNumber(1)); client.HGET(hash, field, helper.isString(value.toString(), done)); }); diff --git a/test/commands/incr.spec.js b/test/commands/incr.spec.js index bc303da..f4d6b8e 100644 --- a/test/commands/incr.spec.js +++ b/test/commands/incr.spec.js @@ -69,7 +69,7 @@ describe("The 'incr' method", function () { }); it("changes the last digit from 2 to 3", function (done) { - client.incr(key, function (err, res) { + client.INCR(key, function (err, res) { helper.isString("9007199254740993")(err, res); done(err); }); diff --git a/test/commands/keys.spec.js b/test/commands/keys.spec.js index aaf6dda..664ec4e 100644 --- a/test/commands/keys.spec.js +++ b/test/commands/keys.spec.js @@ -46,7 +46,7 @@ describe("The 'keys' method", function () { return a.concat(b); }), helper.isString("OK")); - client.KEYS("multibulk:*", function(err, results) { + client.keys("multibulk:*", function(err, results) { assert.deepEqual(keys_values.map(function(val) { return val[0]; }).sort(), results.sort()); diff --git a/test/commands/mget.spec.js b/test/commands/mget.spec.js index 270ff37..3d506c6 100644 --- a/test/commands/mget.spec.js +++ b/test/commands/mget.spec.js @@ -33,7 +33,7 @@ describe("The 'mget' method", function () { }); it('handles fetching multiple keys via an array', function (done) { - client.MGET(["mget keys 1", "mget keys 2", "mget keys 3"], function (err, results) { + client.mget(["mget keys 1", "mget keys 2", "mget keys 3"], function (err, results) { assert.strictEqual("mget val 1", results[0].toString()); assert.strictEqual("mget val 2", results[1].toString()); assert.strictEqual("mget val 3", results[2].toString()); diff --git a/test/commands/msetnx.spec.js b/test/commands/msetnx.spec.js index 8084677..1ac77e1 100644 --- a/test/commands/msetnx.spec.js +++ b/test/commands/msetnx.spec.js @@ -26,7 +26,7 @@ describe("The 'msetnx' method", function () { }); it('sets multiple keys if all keys are not set', function (done) { - client.MSETNX(["mset3", "val3", "mset4", "val4"], helper.isNumber(1)); + client.msetnx(["mset3", "val3", "mset4", "val4"], helper.isNumber(1)); client.exists(["mset3"], helper.isNumber(1)); client.exists(["mset3"], helper.isNumber(1, done)); }); diff --git a/test/commands/multi.spec.js b/test/commands/multi.spec.js index 41ae51f..11aae4f 100644 --- a/test/commands/multi.spec.js +++ b/test/commands/multi.spec.js @@ -62,7 +62,7 @@ describe("The 'multi' method", function () { var multi1, multi2; // Provoke an error at queue time - multi1 = client.multi(); + multi1 = client.MULTI(); multi1.mset("multifoo", "10", "multibar", "20", helper.isString("OK")); multi1.set("foo2", helper.isError()); multi1.incr("multifoo", helper.isNumber(11)); diff --git a/test/commands/rename.spec.js b/test/commands/rename.spec.js index 6196994..d506bec 100644 --- a/test/commands/rename.spec.js +++ b/test/commands/rename.spec.js @@ -21,7 +21,7 @@ describe("The 'rename' method", function () { it('populates the new key', function (done) { client.set(['foo', 'bar'], helper.isString("OK")); - client.RENAME(["foo", "new foo"], helper.isString("OK")); + client.rename(["foo", "new foo"], helper.isString("OK")); client.exists(["new foo"], helper.isNumber(1, done)); }); diff --git a/test/commands/renamenx.spec.js b/test/commands/renamenx.spec.js index 454d046..dc2224e 100644 --- a/test/commands/renamenx.spec.js +++ b/test/commands/renamenx.spec.js @@ -21,7 +21,7 @@ describe("The 'renamenx' method", function () { it('renames the key if target does not yet exist', function (done) { client.set('foo', 'bar', helper.isString('OK')); - client.renamenx('foo', 'foo2', helper.isNumber(1)); + client.RENAMENX('foo', 'foo2', helper.isNumber(1)); client.exists('foo', helper.isNumber(0)); client.exists(['foo2'], helper.isNumber(1, done)); }); diff --git a/test/commands/script.spec.js b/test/commands/script.spec.js index 254ab60..663bbc5 100644 --- a/test/commands/script.spec.js +++ b/test/commands/script.spec.js @@ -33,7 +33,7 @@ describe("The 'script' method", function () { }); it("loads script with client.script('load')", function (done) { - client.script("load", command, function(err, result) { + client.SCRIPT("load", command, function(err, result) { assert.strictEqual(result, commandSha); return done(); }); diff --git a/test/commands/select.spec.js b/test/commands/select.spec.js index bdc8766..1f0c385 100644 --- a/test/commands/select.spec.js +++ b/test/commands/select.spec.js @@ -48,7 +48,7 @@ describe("The 'select' method", function () { it("changes the database and calls the callback", function (done) { // default value of null means database 0 will be used. assert.strictEqual(client.selected_db, null, "default db should be null"); - client.select(1, function (err, res) { + client.SELECT(1, function (err, res) { helper.isNotError()(err, res); assert.strictEqual(client.selected_db, 1, "db should be 1 after select"); done(); diff --git a/test/commands/set.spec.js b/test/commands/set.spec.js index 1674051..1ef70fc 100644 --- a/test/commands/set.spec.js +++ b/test/commands/set.spec.js @@ -58,7 +58,7 @@ describe("The 'set' method", function () { describe("and a callback is specified", function () { describe("with valid parameters", function () { it("sets the value correctly", function (done) { - client.set(key, value, function (err, res) { + client.SET(key, value, function (err, res) { helper.isNotError()(err, res); client.get(key, function (err, res) { helper.isString(value)(err, res); diff --git a/test/commands/setex.spec.js b/test/commands/setex.spec.js index 71e55b2..334f92c 100644 --- a/test/commands/setex.spec.js +++ b/test/commands/setex.spec.js @@ -21,7 +21,7 @@ describe("The 'setex' method", function () { }); it('sets a key with an expiry', function (done) { - client.SETEX(["setex key", "100", "setex val"], helper.isString("OK")); + client.setex(["setex key", "100", "setex val"], helper.isString("OK")); client.exists(["setex key"], helper.isNumber(1)); client.ttl(['setex key'], function (err, ttl) { assert.ok(ttl > 0); diff --git a/test/commands/setnx.spec.js b/test/commands/setnx.spec.js index 8e426d6..0092a33 100644 --- a/test/commands/setnx.spec.js +++ b/test/commands/setnx.spec.js @@ -20,7 +20,7 @@ describe("The 'setnx' method", function () { }); it('sets key if it does not have a value', function (done) { - client.setnx('foo', 'banana', helper.isNumber(1)); + client.SETNX('foo', 'banana', helper.isNumber(1)); client.get('foo', helper.isString('banana', done)); }); diff --git a/test/commands/sinter.spec.js b/test/commands/sinter.spec.js index 59b751f..e039737 100644 --- a/test/commands/sinter.spec.js +++ b/test/commands/sinter.spec.js @@ -29,7 +29,7 @@ describe("The 'sinter' method", function () { client.sadd('sb', 'c', helper.isNumber(1)); client.sadd('sb', 'd', helper.isNumber(1)); - client.sinter('sa', 'sb', function (err, intersection) { + client.SINTER('sa', 'sb', function (err, intersection) { assert.equal(intersection.length, 2); assert.deepEqual(intersection.sort(), [ 'b', 'c' ]); return done(err); diff --git a/test/commands/sismember.spec.js b/test/commands/sismember.spec.js index 1e1d29e..d5e4a55 100644 --- a/test/commands/sismember.spec.js +++ b/test/commands/sismember.spec.js @@ -25,7 +25,7 @@ describe("The 'sismember' method", function () { it('returns 1 if the value is in the set', function (done) { client.sadd('foo', 'banana', helper.isNumber(1)); - client.sismember('foo', 'banana', helper.isNumber(1, done)); + client.SISMEMBER('foo', 'banana', helper.isNumber(1, done)); }); afterEach(function () { diff --git a/test/commands/slowlog.spec.js b/test/commands/slowlog.spec.js index c64b0eb..846694d 100644 --- a/test/commands/slowlog.spec.js +++ b/test/commands/slowlog.spec.js @@ -25,7 +25,7 @@ describe("The 'slowlog' method", function () { client.slowlog("reset", helper.isString("OK")); client.set("foo", "bar", helper.isString("OK")); client.get("foo", helper.isString("bar")); - client.slowlog("get", function (err, res) { + client.SLOWLOG("get", function (err, res) { assert.equal(res.length, 3); assert.equal(res[0][3].length, 2); assert.deepEqual(res[1][3], ["set", "foo", "bar"]); diff --git a/test/commands/smove.spec.js b/test/commands/smove.spec.js index abdc2e4..4b65b15 100644 --- a/test/commands/smove.spec.js +++ b/test/commands/smove.spec.js @@ -28,7 +28,7 @@ describe("The 'smove' method", function () { it("does not move a value if it does not exist in the first set", function (done) { client.sadd('foo', 'x', helper.isNumber(1)); - client.smove('foo', 'bar', 'y', helper.isNumber(0)); + client.SMOVE('foo', 'bar', 'y', helper.isNumber(0)); client.sismember('foo', 'y', helper.isNumber(0)); client.sismember('bar', 'y', helper.isNumber(0, done)); }); diff --git a/test/commands/sort.spec.js b/test/commands/sort.spec.js index d50f176..e598513 100644 --- a/test/commands/sort.spec.js +++ b/test/commands/sort.spec.js @@ -30,7 +30,7 @@ describe("The 'sort' method", function () { }); it('sorts in descending alphabetical order', function (done) { - client.sort('y', 'desc', 'alpha', function (err, sorted) { + client.SORT('y', 'desc', 'alpha', function (err, sorted) { assert.deepEqual(sorted, ['d', 'c', 'b', 'a']); return done(err); }); diff --git a/test/commands/srem.spec.js b/test/commands/srem.spec.js index a62dd6b..8afd79a 100644 --- a/test/commands/srem.spec.js +++ b/test/commands/srem.spec.js @@ -27,7 +27,7 @@ describe("The 'srem' method", function () { }); it('handles attempting to remove a missing value', function (done) { - client.srem('set0', 'member0', helper.isNumber(0, done)); + client.SREM('set0', 'member0', helper.isNumber(0, done)); }); it('allows multiple values to be removed', function (done) { diff --git a/test/commands/type.spec.js b/test/commands/type.spec.js index 1410b32..e4ad527 100644 --- a/test/commands/type.spec.js +++ b/test/commands/type.spec.js @@ -26,7 +26,7 @@ describe("The 'type' method", function () { it('reports list type', function (done) { client.rpush(["list key", "should be a list"], helper.isNumber(1)); - client.TYPE(["list key"], helper.isString("list", done)); + client.type(["list key"], helper.isString("list", done)); }); it('reports set type', function (done) { diff --git a/test/commands/watch.spec.js b/test/commands/watch.spec.js index 6cbc63e..11cd447 100644 --- a/test/commands/watch.spec.js +++ b/test/commands/watch.spec.js @@ -32,7 +32,7 @@ describe("The 'watch' method", function () { }); it('does not execute transaction if watched key was modified prior to execution', function (done) { - client.watch(watched); + client.WATCH(watched); client.incr(watched); var multi = client.multi(); multi.incr(watched);