Node.js Redis operation: concurrent browsing over one connection
Playing with nodejs, socket.io and redis transaction.
Amazing what will happen with this code (dummy code)
var redis = require('redis');
var client = redis.createClient();
...
socket.on('setSomeKey', function() {
client.watch('someKey');
client.get('someKey',function(err,replies) {
client.multi().set('someKey','someValue').exec();
});
});
socket.on('setSomeStuff', function() {
client.watch('someStuff');
client.set('someStuff','blip');
...
});
Client 1 sends event "setSomeKey":
-> redis watch someKey
-> redis get someKey and wait for response
Client 2 sends an event "setSomeStuff"
-> redis watch someStuff
-> redis set someStuff and wait for a response
Client 1: -> gets "someKey" and tries to use multi..exec:
=> Will the clock on "someStuff" set by client2 affect multi exec?
In other words, can this happen when watching redis with MONITOR:
- watch online - get someKey
- watch some stuff
- set someStuff
- multi
- exec => FAIL because of "watch someStuff" which has changes between get and multi. .exec executed in the callback?
No one has answered this question yet
Check out similar questions: