From 9e5a7b96b39856250d6ca607b6a6827db7310bd8 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 24 Apr 2013 22:20:05 -0400 Subject: [PATCH] fixed broken mget implementation if no topics are present --- src/redis.js | 4 ++-- src/topics.js | 51 ++++++++++++++++++++++++------------------------ src/webserver.js | 17 +++++++++++++--- 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/redis.js b/src/redis.js index 0c2a6d2e04..e7ace192c4 100644 --- a/src/redis.js +++ b/src/redis.js @@ -5,8 +5,8 @@ redis = require('redis'), db = redis.createClient(); - // todo (holy cow): append,auth,bgrewriteaof,bgsave,bitcount,bitop,blpop,brpop,brpoplpush,client kill,client list,client getname,client setname,config get,config set,config resetstat,dbsize,debug object,debug segfault,decrby,del,discard,dump,echo,eval,evalsha,exec,exists,expire,expireat,flushall,flushdb,getbit,getrange,getset,hdel,hexists,hget,hgetall,hincrby,hincrbyfloat,hkeys,hlen,hmget,hmset,hset,hsetnx,hvals,incrby,incrbyfloat,info,keys,lastsave,lindex,linsert,llen,lpop,lpush,lpushx,lrange,lrem,lset,ltrim,mget,migrate,monitor,move,mset,msetnx,multi,object,persist,pexpire,pexpireat,ping,psetex,psubscribe,pttl,publish,punsubscribe,quit,randomkey,rename,renamenx,restore,rpop,rpoplpush,rpush,rpushx,sadd,save,scard,script exists,script flush,script kill,script load,sdiff,sdiffstore,select,setbit,setex,setnx,setrange,shutdown,sinter,sinterstore,sismember,slaveof,slowlog,smembers,smove,sort,spop,srandmember,srem,strlen,subscribe,sunion,sunionstore,sync,time,ttl,type,unsubscribe,unwatch,watch,zadd,zcard,zcount,zincrby,zinterstore,zrange,zrangebyscore,zrank,zrem,zremrangebyrank,zremrangebyscore,zrevrange,zrevrangebyscore,zrevrank,zscore,zunionstore - // done :^) get, set, incr, decr + // todo (holy cow): append,auth,bgrewriteaof,bgsave,bitcount,bitop,blpop,brpop,brpoplpush,client kill,client list,client getname,client setname,config get,config set,config resetstat,dbsize,debug object,debug segfault,decrby,discard,dump,echo,eval,evalsha,exec,exists,expireat,flushall,flushdb,getbit,getrange,getset,hdel,hexists,hget,hgetall,hincrby,hincrbyfloat,hkeys,hlen,hmget,hmset,hset,hsetnx,hvals,incrby,incrbyfloat,info,keys,lastsave,lindex,linsert,llen,lpop,lpushx,lrem,lset,ltrim,migrate,monitor,move,mset,msetnx,object,persist,pexpire,pexpireat,ping,psetex,psubscribe,pttl,publish,punsubscribe,quit,randomkey,rename,renamenx,restore,rpop,rpoplpush,rpush,rpushx,sadd,save,scard,script exists,script flush,script kill,script load,sdiff,sdiffstore,select,setbit,setex,setnx,setrange,shutdown,sinter,sinterstore,sismember,slaveof,slowlog,smembers,smove,sort,spop,srandmember,srem,strlen,subscribe,sunion,sunionstore,sync,time,ttl,type,unsubscribe,unwatch,watch,zadd,zcard,zcount,zincrby,zinterstore,zrange,zrangebyscore,zrank,zrem,zremrangebyrank,zremrangebyscore,zrevrange,zrevrangebyscore,zrevrank,zscore,zunionstore + // done: get, set, incr, decr, del, mget, multi, expire, lpush, lrange function return_handler(error, data, callback, error_handler) { if (error !== null) { diff --git a/src/topics.js b/src/topics.js index 7af7f2eee8..8c28cd13e1 100644 --- a/src/topics.js +++ b/src/topics.js @@ -53,33 +53,34 @@ var RDB = require('./redis.js'), callback(topic_data); });*/ - RDB.multi() - .mget(title) - .mget(uid) - .mget(timestamp) - .mget(posts) - .exec(function(err, replies) { - title = replies[0]; - uid = replies[1]; - timestamp = replies[2]; - posts = replies[3]; - - var topics = []; - for (var i=0, ii=title.length; i 0) { + RDB.multi() + .mget(title) + .mget(uid) + .mget(timestamp) + .mget(posts) + .exec(function(err, replies) { + title = replies[0]; + uid = replies[1]; + timestamp = replies[2]; + posts = replies[3]; + + var topics = []; + for (var i=0, ii=title.length; i