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?
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!
Discussion
View additional discussion.