Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Do I need to wait for a callback on a call to WATCH in Redis (in node.js)?

Do I need to wait for a callback on a call to WATCH in Redis (in node.js)?

Problem

I'm using node-redis. In code like this:

var store = require('redis').createClient();
store.watch('some:key');
store.get('some:key', function (err, results) {
   var multi = store.multi();
   // COMPUTE SOMETHING WITH results
   multi.set('something:or:other', 25);
   multi.exec(checkAllIsWell);
});

Should lines 1-2 read

store.watch('some:key', function (err, alwaysok) {
  store.get('some:key', function (err, result) { 

or will watch always have immediate effect?

EDIT: To reframe the question a little, is sequence guaranteed on seqential calls on the same Redis client? Or could the WATCH happen after the GET?

Problem courtesy of: Grumdrig

Solution

Having reframed my question, I realize that it must surely be sequence-preserving, and I'm actually duplicating this question: Are Redis updates synchronous?

So the answer is surely that I don't need to wait for WATCH to call back and my original code is OK.

Sorry to noise up the web, folks!

Solution courtesy of: Grumdrig

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Do I need to wait for a callback on a call to WATCH in Redis (in node.js)?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×