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

Add static list of commands to those downloaded from redis.io.

This commit is contained in:
Matt Ranney
2011-06-28 22:48:30 -07:00
parent 4b988bdb60
commit 707c9ab3df
4 changed files with 32 additions and 6 deletions

View File

@@ -517,6 +517,8 @@ Defaults to 1.7. The default initial connection retry is 250, so the second ret
## TODO ## TODO
Better tests for monitor mode, auth, disconnect/reconnect, and all combinations thereof.
Stream large set/get values into and out of Redis. Otherwise the entire value must be in node's memory. Stream large set/get values into and out of Redis. Otherwise the entire value must be in node's memory.
Performance can be better for very large values. Performance can be better for very large values.

View File

@@ -18,7 +18,7 @@ function write_file(commands, path) {
return key.toLowerCase(); return key.toLowerCase();
}); });
file_contents += "exports.Commands = " + JSON.stringify(out_commands, null, " ") + ";\n"; file_contents += "module.exports = " + JSON.stringify(out_commands, null, " ") + ";\n";
fs.writeFile(path, file_contents); fs.writeFile(path, file_contents);
} }

View File

@@ -1,12 +1,11 @@
/*global Buffer require exports console setTimeout */ /*global Buffer require exports console setTimeout */
var net = require("net"), var net = require("net"),
Commands = require("./lib/commands").Commands,
util = require("./lib/util").util, util = require("./lib/util").util,
Queue = require("./lib/queue").Queue, Queue = require("./lib/queue").Queue,
to_array = require("./lib/to_array"), to_array = require("./lib/to_array"),
events = require("events"), events = require("events"),
parsers = [], parsers = [], commands,
default_port = 6379, default_port = 6379,
default_host = "127.0.0.1"; default_host = "127.0.0.1";
@@ -569,7 +568,32 @@ function Multi(client, args) {
} }
} }
Commands.forEach(function (command) { // 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 (command) {
RedisClient.prototype[command] = function () { RedisClient.prototype[command] = function () {
var args = to_array(arguments); var args = to_array(arguments);
args.unshift(command); // put command at the beginning args.unshift(command); // put command at the beginning

View File

@@ -1,5 +1,5 @@
// This file was generated by ./generate_commands.js on Sun Jun 12 2011 14:25:05 GMT-1000 (HST) // This file was generated by ./generate_commands.js on Tue Jun 28 2011 22:37:02 GMT-0700 (PDT)
exports.Commands = [ module.exports = [
"append", "append",
"auth", "auth",
"bgrewriteaof", "bgrewriteaof",