node.js - Get key from Redis and expire it at the same time -


i have queue backed-up redis, multiple node connections redis server, , need make sure won't same key twice, never run same task more once.

i'm using node-redis task:

client.set("some_key", data); client.get("some_key", function (err, data) {     //..  }); 

how can make sure when getting key no other node process able too? if set expired after getting value won't enough when 2 process try same value @ same time.

i don't think there's other way wrap in multi

multi some_key del some_key exec 

so using node-redis, like

 client.multi() .get("some_key", data).del("some_key"). .exec(function (err, replies) {}); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -