@@ -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
893896exports . 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-
920898commands . 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
0 commit comments