diff --git a/README.md b/README.md index 8823f967a5..c2f4435336 100644 --- a/README.md +++ b/README.md @@ -517,6 +517,8 @@ Defaults to 1.7. The default initial connection retry is 250, so the second ret ## 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. Performance can be better for very large values. diff --git a/generate_commands.js b/generate_commands.js index fa6a10e014..e94d74ec4a 100644 --- a/generate_commands.js +++ b/generate_commands.js @@ -18,7 +18,7 @@ function write_file(commands, path) { 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); } diff --git a/index.js b/index.js index aa35e0e0d5..6f55fa6ef8 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,11 @@ /*global Buffer require exports console setTimeout */ var net = require("net"), - Commands = require("./lib/commands").Commands, util = require("./lib/util").util, Queue = require("./lib/queue").Queue, to_array = require("./lib/to_array"), events = require("events"), - parsers = [], + parsers = [], commands, default_port = 6379, 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 () { var args = to_array(arguments); args.unshift(command); // put command at the beginning diff --git a/lib/commands.js b/lib/commands.js index dddcd86b53..0293ae8d37 100644 --- a/lib/commands.js +++ b/lib/commands.js @@ -1,5 +1,5 @@ -// This file was generated by ./generate_commands.js on Sun Jun 12 2011 14:25:05 GMT-1000 (HST) -exports.Commands = [ +// This file was generated by ./generate_commands.js on Tue Jun 28 2011 22:37:02 GMT-0700 (PDT) +module.exports = [ "append", "auth", "bgrewriteaof",