@@ -7,7 +7,10 @@ var net = require("net"),
7
7
to_array = require ( "./lib/to_array" ) ,
8
8
events = require ( "events" ) ,
9
9
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" ) ,
11
14
connection_id = 0 ,
12
15
default_port = 6379 ,
13
16
default_host = "127.0.0.1" ,
@@ -892,40 +895,19 @@ function Multi(client, args) {
892
895
893
896
exports . Multi = Multi ;
894
897
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
-
920
898
commands . forEach ( function ( fullCommand ) {
921
899
var command = fullCommand . split ( ' ' ) [ 0 ] ;
922
900
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
+
923
906
RedisClient . prototype [ command ] = function ( args , callback ) {
924
907
if ( Array . isArray ( args ) ) {
925
908
return this . send_command ( command , args , callback ) ;
926
- } else {
927
- return this . send_command ( command , to_array ( arguments ) ) ;
928
909
}
910
+ return this . send_command ( command , to_array ( arguments ) ) ;
929
911
} ;
930
912
RedisClient . prototype [ command . toUpperCase ( ) ] = RedisClient . prototype [ command ] ;
931
913
0 commit comments