I have a simple script and read-only database redis.
var redis = require('redis'),
client = redis.createClient(), multi
client.on('error', function(error) {
console.log('error')
})
tasks = []
tasks.push(['set', 'a', 1 ])
tasks.push(['set', 'b', 1 ])
client.multi(this.tasks).exec(function (err, replies) {
console.log(err)
tasks = []
tasks.push(['set', 'a', 1 ])
client.multi(tasks).exec(function (err, replies) {
console.log(err)
})
})
Result of this script:
null
null
/usr/local/lstat/lstat/node_modules/redis/index.js:468
throw callback_err;
^
Error: Error: Error: READONLY You can't write against a read only slave.
How to catch this exception ?