1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Update commands list and remove unecessary code

Add use strict

Add changelog entry
This commit is contained in:
Ruben Bridgewater
2015-09-03 21:50:29 +02:00
parent feb1faa824
commit b06985a219
4 changed files with 45 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ Changelog
## Upcoming ## Upcoming
* [#815](https://github.com/NodeRedis/node_redis/pull/815) Consistently use new debug functionality (@BridgeAR) * [#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 ## v1.0.0 - Aug 30, 2015

View File

@@ -13,7 +13,7 @@ function write_file(commands, path) {
console.log("Writing " + Object.keys(commands).length + " commands to " + 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) { out_commands = Object.keys(commands).map(function (key) {
return key.toLowerCase(); return key.toLowerCase();

View File

@@ -7,7 +7,10 @@ var net = require("net"),
to_array = require("./lib/to_array"), to_array = require("./lib/to_array"),
events = require("events"), events = require("events"),
crypto = require("crypto"), 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, connection_id = 0,
default_port = 6379, default_port = 6379,
default_host = "127.0.0.1", default_host = "127.0.0.1",
@@ -892,40 +895,19 @@ function Multi(client, args) {
exports.Multi = Multi; 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) { commands.forEach(function (fullCommand) {
var command = fullCommand.split(' ')[0]; 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) { RedisClient.prototype[command] = function (args, callback) {
if (Array.isArray(args)) { if (Array.isArray(args)) {
return this.send_command(command, args, callback); 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]; RedisClient.prototype[command.toUpperCase()] = RedisClient.prototype[command];

View File

@@ -1,6 +1,6 @@
'use strict'; '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 = [ module.exports = [
"append", "append",
"auth", "auth",
@@ -17,6 +17,28 @@ module.exports = [
"client getname", "client getname",
"client pause", "client pause",
"client setname", "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 get",
"config rewrite", "config rewrite",
"config set", "config set",
@@ -38,6 +60,12 @@ module.exports = [
"expireat", "expireat",
"flushall", "flushall",
"flushdb", "flushdb",
"geoadd",
"geohash",
"geopos",
"geodist",
"georadius",
"georadiusbymember",
"get", "get",
"getbit", "getbit",
"getrange", "getrange",
@@ -54,6 +82,7 @@ module.exports = [
"hmset", "hmset",
"hset", "hset",
"hsetnx", "hsetnx",
"hstrlen",
"hvals", "hvals",
"incr", "incr",
"incrby", "incrby",
@@ -97,6 +126,7 @@ module.exports = [
"rename", "rename",
"renamenx", "renamenx",
"restore", "restore",
"role",
"rpop", "rpop",
"rpoplpush", "rpoplpush",
"rpush", "rpush",
@@ -138,6 +168,7 @@ module.exports = [
"type", "type",
"unsubscribe", "unsubscribe",
"unwatch", "unwatch",
"wait",
"watch", "watch",
"zadd", "zadd",
"zcard", "zcard",
@@ -147,6 +178,7 @@ module.exports = [
"zlexcount", "zlexcount",
"zrange", "zrange",
"zrangebylex", "zrangebylex",
"zrevrangebylex",
"zrangebyscore", "zrangebyscore",
"zrank", "zrank",
"zrem", "zrem",