Skip to content

Commit 4e42fb7

Browse files
committed
Merge pull request #814 from fintura/commands
Update commands list and remove unecessary code
2 parents feb1faa + b06985a commit 4e42fb7

File tree

4 files changed

+45
-30
lines changed

4 files changed

+45
-30
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
## Upcoming
55

66
* [#815](https://github.com/NodeRedis/node_redis/pull/815) Consistently use new debug functionality (@BridgeAR)
7+
* [#814](https://github.com/NodeRedis/node_redis/pull/814) Support new commands and drop support for deprecated 'substr' (@BridgeAR)
78

89
## v1.0.0 - Aug 30, 2015
910

generate_commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function write_file(commands, path) {
1313

1414
console.log("Writing " + Object.keys(commands).length + " commands to " + path);
1515

16-
file_contents = "// This file was generated by ./generate_commands.js on " + prettyCurrentTime() + "\n";
16+
file_contents = "'use strict';\n\n// This file was generated by ./generate_commands.js on " + prettyCurrentTime() + "\n";
1717

1818
out_commands = Object.keys(commands).map(function (key) {
1919
return key.toLowerCase();

index.js

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ var net = require("net"),
77
to_array = require("./lib/to_array"),
88
events = require("events"),
99
crypto = require("crypto"),
10-
parsers = [], commands,
10+
parsers = [],
11+
// This static list of commands is updated from time to time.
12+
// ./lib/commands.js can be updated with generate_commands.js
13+
commands = require("./lib/commands"),
1114
connection_id = 0,
1215
default_port = 6379,
1316
default_host = "127.0.0.1",
@@ -892,40 +895,19 @@ function Multi(client, args) {
892895

893896
exports.Multi = Multi;
894897

895-
// take 2 arrays and return the union of their elements
896-
function set_union(seta, setb) {
897-
var obj = {};
898-
899-
seta.forEach(function (val) {
900-
obj[val] = true;
901-
});
902-
setb.forEach(function (val) {
903-
obj[val] = true;
904-
});
905-
return Object.keys(obj);
906-
}
907-
908-
// This static list of commands is updated from time to time. ./lib/commands.js can be updated with generate_commands.js
909-
commands = set_union(["get", "set", "setnx", "setex", "append", "strlen", "del", "exists", "setbit", "getbit", "setrange", "getrange", "substr",
910-
"incr", "decr", "mget", "rpush", "lpush", "rpushx", "lpushx", "linsert", "rpop", "lpop", "brpop", "brpoplpush", "blpop", "llen", "lindex",
911-
"lset", "lrange", "ltrim", "lrem", "rpoplpush", "sadd", "srem", "smove", "sismember", "scard", "spop", "srandmember", "sinter", "sinterstore",
912-
"sunion", "sunionstore", "sdiff", "sdiffstore", "smembers", "zadd", "zincrby", "zrem", "zremrangebyscore", "zremrangebyrank", "zunionstore",
913-
"zinterstore", "zrange", "zrangebyscore", "zrevrangebyscore", "zcount", "zrevrange", "zcard", "zscore", "zrank", "zrevrank", "hset", "hsetnx",
914-
"hget", "hmset", "hmget", "hincrby", "hdel", "hlen", "hkeys", "hvals", "hgetall", "hexists", "incrby", "decrby", "getset", "mset", "msetnx",
915-
"randomkey", "select", "move", "rename", "renamenx", "expire", "expireat", "keys", "dbsize", "auth", "ping", "echo", "save", "bgsave",
916-
"bgrewriteaof", "shutdown", "lastsave", "type", "multi", "exec", "discard", "sync", "flushdb", "flushall", "sort", "info", "monitor", "ttl",
917-
"persist", "slaveof", "debug", "config", "subscribe", "unsubscribe", "psubscribe", "punsubscribe", "publish", "watch", "unwatch", "cluster",
918-
"restore", "migrate", "dump", "object", "client", "eval", "evalsha"], require("./lib/commands"));
919-
920898
commands.forEach(function (fullCommand) {
921899
var command = fullCommand.split(' ')[0];
922900

901+
// Skip all full commands that have already been added instead of overwriting them over and over again
902+
if (RedisClient.prototype[command]) {
903+
return;
904+
}
905+
923906
RedisClient.prototype[command] = function (args, callback) {
924907
if (Array.isArray(args)) {
925908
return this.send_command(command, args, callback);
926-
} else {
927-
return this.send_command(command, to_array(arguments));
928909
}
910+
return this.send_command(command, to_array(arguments));
929911
};
930912
RedisClient.prototype[command.toUpperCase()] = RedisClient.prototype[command];
931913

lib/commands.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
// This file was generated by ./generate_commands.js on Wed Apr 23 2014 14:51:21 GMT-0700 (PDT)
3+
// This file was generated by ./generate_commands.js on Thu Sep 03 2015 02:40:54 GMT+0200 (CEST)
44
module.exports = [
55
"append",
66
"auth",
@@ -17,6 +17,28 @@ module.exports = [
1717
"client getname",
1818
"client pause",
1919
"client setname",
20+
"cluster addslots",
21+
"cluster count-failure-reports",
22+
"cluster countkeysinslot",
23+
"cluster delslots",
24+
"cluster failover",
25+
"cluster forget",
26+
"cluster getkeysinslot",
27+
"cluster info",
28+
"cluster keyslot",
29+
"cluster meet",
30+
"cluster nodes",
31+
"cluster replicate",
32+
"cluster reset",
33+
"cluster saveconfig",
34+
"cluster set-config-epoch",
35+
"cluster setslot",
36+
"cluster slaves",
37+
"cluster slots",
38+
"command",
39+
"command count",
40+
"command getkeys",
41+
"command info",
2042
"config get",
2143
"config rewrite",
2244
"config set",
@@ -38,6 +60,12 @@ module.exports = [
3860
"expireat",
3961
"flushall",
4062
"flushdb",
63+
"geoadd",
64+
"geohash",
65+
"geopos",
66+
"geodist",
67+
"georadius",
68+
"georadiusbymember",
4169
"get",
4270
"getbit",
4371
"getrange",
@@ -54,6 +82,7 @@ module.exports = [
5482
"hmset",
5583
"hset",
5684
"hsetnx",
85+
"hstrlen",
5786
"hvals",
5887
"incr",
5988
"incrby",
@@ -97,6 +126,7 @@ module.exports = [
97126
"rename",
98127
"renamenx",
99128
"restore",
129+
"role",
100130
"rpop",
101131
"rpoplpush",
102132
"rpush",
@@ -138,6 +168,7 @@ module.exports = [
138168
"type",
139169
"unsubscribe",
140170
"unwatch",
171+
"wait",
141172
"watch",
142173
"zadd",
143174
"zcard",
@@ -147,6 +178,7 @@ module.exports = [
147178
"zlexcount",
148179
"zrange",
149180
"zrangebylex",
181+
"zrevrangebylex",
150182
"zrangebyscore",
151183
"zrank",
152184
"zrem",

0 commit comments

Comments
 (0)