node.js - Store timestamp each users in sorted set Redis -
node.js - Store timestamp each users in sorted set Redis -
i have little code:
add id:
redis.zadd('onlineusers', time, id, function (err, response) { //todo });
is right way save current timestamp user him id?
delete id key:
db.zrem('onlineusers', data.id);
also, how multiple values sorted set keys: 1,2,3
is right way save current timestamp user him id?
yes
you can scores of multiple values using multi.
function getscores(setkey, values, callback) { var multi = db.multi(); for(var i=0; i<values.length; ++i) { multi.zscore(setkey, values[i]); } multi.exec(callback); }
usage
getscores('onlineusers', [1,2,3], function(err, scores) { console.log(err, scores); });
node.js redis
Comments
Post a Comment