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

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -