diff --git a/changelog.md b/changelog.md index 085cdae2bf..15588a4eae 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ Changelog ## Upcoming * [#815](https://github.com/NodeRedis/node_redis/pull/815) Consistently use new debug functionality (@BridgeAR) +* [#814](https://github.com/NodeRedis/node_redis/pull/814) Support new commands and drop support for deprecated 'substr' (@BridgeAR) ## v1.0.0 - Aug 30, 2015 diff --git a/generate_commands.js b/generate_commands.js index 3ad420edc3..a9862321f6 100644 --- a/generate_commands.js +++ b/generate_commands.js @@ -13,7 +13,7 @@ function write_file(commands, path) { console.log("Writing " + Object.keys(commands).length + " commands to " + path); - file_contents = "// This file was generated by ./generate_commands.js on " + prettyCurrentTime() + "\n"; + file_contents = "'use strict';\n\n// This file was generated by ./generate_commands.js on " + prettyCurrentTime() + "\n"; out_commands = Object.keys(commands).map(function (key) { return key.toLowerCase(); diff --git a/index.js b/index.js index 7b1ea0345a..b2b8aa2932 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,10 @@ var net = require("net"), to_array = require("./lib/to_array"), events = require("events"), crypto = require("crypto"), - parsers = [], commands, + parsers = [], + // This static list of commands is updated from time to time. + // ./lib/commands.js can be updated with generate_commands.js + commands = require("./lib/commands"), connection_id = 0, default_port = 6379, default_host = "127.0.0.1", @@ -892,40 +895,19 @@ function Multi(client, args) { exports.Multi = Multi; -// take 2 arrays and return the union of their elements -function set_union(seta, setb) { - var obj = {}; - - seta.forEach(function (val) { - obj[val] = true; - }); - setb.forEach(function (val) { - obj[val] = true; - }); - return Object.keys(obj); -} - -// This static list of commands is updated from time to time. ./lib/commands.js can be updated with generate_commands.js -commands = set_union(["get", "set", "setnx", "setex", "append", "strlen", "del", "exists", "setbit", "getbit", "setrange", "getrange", "substr", - "incr", "decr", "mget", "rpush", "lpush", "rpushx", "lpushx", "linsert", "rpop", "lpop", "brpop", "brpoplpush", "blpop", "llen", "lindex", - "lset", "lrange", "ltrim", "lrem", "rpoplpush", "sadd", "srem", "smove", "sismember", "scard", "spop", "srandmember", "sinter", "sinterstore", - "sunion", "sunionstore", "sdiff", "sdiffstore", "smembers", "zadd", "zincrby", "zrem", "zremrangebyscore", "zremrangebyrank", "zunionstore", - "zinterstore", "zrange", "zrangebyscore", "zrevrangebyscore", "zcount", "zrevrange", "zcard", "zscore", "zrank", "zrevrank", "hset", "hsetnx", - "hget", "hmset", "hmget", "hincrby", "hdel", "hlen", "hkeys", "hvals", "hgetall", "hexists", "incrby", "decrby", "getset", "mset", "msetnx", - "randomkey", "select", "move", "rename", "renamenx", "expire", "expireat", "keys", "dbsize", "auth", "ping", "echo", "save", "bgsave", - "bgrewriteaof", "shutdown", "lastsave", "type", "multi", "exec", "discard", "sync", "flushdb", "flushall", "sort", "info", "monitor", "ttl", - "persist", "slaveof", "debug", "config", "subscribe", "unsubscribe", "psubscribe", "punsubscribe", "publish", "watch", "unwatch", "cluster", - "restore", "migrate", "dump", "object", "client", "eval", "evalsha"], require("./lib/commands")); - commands.forEach(function (fullCommand) { var command = fullCommand.split(' ')[0]; + // Skip all full commands that have already been added instead of overwriting them over and over again + if (RedisClient.prototype[command]) { + return; + } + RedisClient.prototype[command] = function (args, callback) { if (Array.isArray(args)) { return this.send_command(command, args, callback); - } else { - return this.send_command(command, to_array(arguments)); } + return this.send_command(command, to_array(arguments)); }; RedisClient.prototype[command.toUpperCase()] = RedisClient.prototype[command]; diff --git a/lib/commands.js b/lib/commands.js index 3b01543d99..8082841dc8 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -1,6 +1,6 @@ 'use strict'; -// This file was generated by ./generate_commands.js on Wed Apr 23 2014 14:51:21 GMT-0700 (PDT) +// This file was generated by ./generate_commands.js on Thu Sep 03 2015 02:40:54 GMT+0200 (CEST) module.exports = [ "append", "auth", @@ -17,6 +17,28 @@ module.exports = [ "client getname", "client pause", "client setname", + "cluster addslots", + "cluster count-failure-reports", + "cluster countkeysinslot", + "cluster delslots", + "cluster failover", + "cluster forget", + "cluster getkeysinslot", + "cluster info", + "cluster keyslot", + "cluster meet", + "cluster nodes", + "cluster replicate", + "cluster reset", + "cluster saveconfig", + "cluster set-config-epoch", + "cluster setslot", + "cluster slaves", + "cluster slots", + "command", + "command count", + "command getkeys", + "command info", "config get", "config rewrite", "config set", @@ -38,6 +60,12 @@ module.exports = [ "expireat", "flushall", "flushdb", + "geoadd", + "geohash", + "geopos", + "geodist", + "georadius", + "georadiusbymember", "get", "getbit", "getrange", @@ -54,6 +82,7 @@ module.exports = [ "hmset", "hset", "hsetnx", + "hstrlen", "hvals", "incr", "incrby", @@ -97,6 +126,7 @@ module.exports = [ "rename", "renamenx", "restore", + "role", "rpop", "rpoplpush", "rpush", @@ -138,6 +168,7 @@ module.exports = [ "type", "unsubscribe", "unwatch", + "wait", "watch", "zadd", "zcard", @@ -147,6 +178,7 @@ module.exports = [ "zlexcount", "zrange", "zrangebylex", + "zrevrangebylex", "zrangebyscore", "zrank", "zrem",