You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Fix send_command always returning should_buffer boolean
Fix .auth, .select and .exec to return the should_buffer boolean
This commit is contained in:
@@ -14,7 +14,8 @@ Features
|
|||||||
|
|
||||||
Bugfixes
|
Bugfixes
|
||||||
|
|
||||||
- Fix a javascript parser regression introduced in 2.0 that could result in timeouts on high load. (@BridgeAR)
|
- Fix a javascript parser regression introduced in 2.0 that could result in timeouts on high load. (@BridgeAR)
|
||||||
|
- Fixed should_buffer boolean for .exec, .select and .auth commands not being returned (@BridgeAR)
|
||||||
|
|
||||||
## v2.1.0 - Oct 02, 2015
|
## v2.1.0 - Oct 02, 2015
|
||||||
|
|
||||||
|
25
index.js
25
index.js
@@ -677,10 +677,11 @@ RedisClient.prototype.send_command = function (command, args, callback) {
|
|||||||
err = new Error('send_command: ' + command + ' value must not be undefined or null');
|
err = new Error('send_command: ' + command + ' value must not be undefined or null');
|
||||||
err.command = command;
|
err.command = command;
|
||||||
if (callback) {
|
if (callback) {
|
||||||
return callback && callback(err);
|
callback(err);
|
||||||
|
} else {
|
||||||
|
this.emit('error', err);
|
||||||
}
|
}
|
||||||
this.emit('error', err);
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -715,7 +716,8 @@ RedisClient.prototype.send_command = function (command, args, callback) {
|
|||||||
this.offline_queue.push(command_obj);
|
this.offline_queue.push(command_obj);
|
||||||
this.should_buffer = true;
|
this.should_buffer = true;
|
||||||
}
|
}
|
||||||
return;
|
// Return false to signal no buffering
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command === 'subscribe' || command === 'psubscribe' || command === 'unsubscribe' || command === 'punsubscribe') {
|
if (command === 'subscribe' || command === 'psubscribe' || command === 'unsubscribe' || command === 'punsubscribe') {
|
||||||
@@ -728,7 +730,7 @@ RedisClient.prototype.send_command = function (command, args, callback) {
|
|||||||
err = new Error('Connection in subscriber mode, only subscriber commands may be used');
|
err = new Error('Connection in subscriber mode, only subscriber commands may be used');
|
||||||
err.command = command.toUpperCase();
|
err.command = command.toUpperCase();
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
this.command_queue.push(command_obj);
|
this.command_queue.push(command_obj);
|
||||||
this.commands_sent += 1;
|
this.commands_sent += 1;
|
||||||
@@ -916,8 +918,7 @@ commands.forEach(function (fullCommand) {
|
|||||||
// store db in this.select_db to restore it on reconnect
|
// store db in this.select_db to restore it on reconnect
|
||||||
RedisClient.prototype.select = RedisClient.prototype.SELECT = function (db, callback) {
|
RedisClient.prototype.select = RedisClient.prototype.SELECT = function (db, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
return this.send_command('select', [db], function (err, res) {
|
||||||
this.send_command('select', [db], function (err, res) {
|
|
||||||
if (err === null) {
|
if (err === null) {
|
||||||
self.selected_db = db;
|
self.selected_db = db;
|
||||||
}
|
}
|
||||||
@@ -939,16 +940,16 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function (pass, callba
|
|||||||
} else {
|
} else {
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
}
|
}
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
this.auth_pass = pass;
|
this.auth_pass = pass;
|
||||||
debug('Saving auth as ' + this.auth_pass);
|
debug('Saving auth as ' + this.auth_pass);
|
||||||
// Only run the callback once. So do not safe it if already connected
|
// Only run the callback once. So do not safe it if already connected
|
||||||
if (this.connected) {
|
if (this.connected) {
|
||||||
this.send_command('auth', [this.auth_pass], callback);
|
return this.send_command('auth', [this.auth_pass], callback);
|
||||||
} else {
|
|
||||||
this.auth_callback = callback;
|
|
||||||
}
|
}
|
||||||
|
this.auth_callback = callback;
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
RedisClient.prototype.hmset = RedisClient.prototype.HMSET = function (key, args, callback) {
|
RedisClient.prototype.hmset = RedisClient.prototype.HMSET = function (key, args, callback) {
|
||||||
@@ -1048,7 +1049,7 @@ Multi.prototype.exec = Multi.prototype.EXEC = function (callback) {
|
|||||||
this.send_command(command, args, index, cb);
|
this.send_command(command, args, index, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._client.send_command('exec', [], function(err, replies) {
|
return this._client.send_command('exec', [], function(err, replies) {
|
||||||
self.execute_callback(err, replies);
|
self.execute_callback(err, replies);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@@ -203,11 +203,12 @@ describe("The 'multi' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('runs a multi without any further commands', function(done) {
|
it('runs a multi without any further commands', function(done) {
|
||||||
client.multi().exec(function(err, res) {
|
var buffering = client.multi().exec(function(err, res) {
|
||||||
assert.strictEqual(err, null);
|
assert.strictEqual(err, null);
|
||||||
assert.strictEqual(res.length, 0);
|
assert.strictEqual(res.length, 0);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
assert(typeof buffering === 'boolean');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows multiple operations to be performed using a chaining API', function (done) {
|
it('allows multiple operations to be performed using a chaining API', function (done) {
|
||||||
|
@@ -24,10 +24,11 @@ describe("The 'select' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("returns an error if redis is not connected", function (done) {
|
it("returns an error if redis is not connected", function (done) {
|
||||||
client.select(1, function (err, res) {
|
var buffering = client.select(1, function (err, res) {
|
||||||
assert(err.message.match(/The connection has already been closed/));
|
assert(err.message.match(/The connection has already been closed/));
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
assert(typeof buffering === 'boolean');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ describe("The 'select' method", function () {
|
|||||||
|
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
client = redis.createClient.apply(redis.createClient, args);
|
client = redis.createClient.apply(redis.createClient, args);
|
||||||
client.once("connect", function () { done(); });
|
client.once("ready", function () { done(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
@@ -46,11 +47,12 @@ describe("The 'select' method", function () {
|
|||||||
it("changes the database and calls the callback", function (done) {
|
it("changes the database and calls the callback", function (done) {
|
||||||
// default value of null means database 0 will be used.
|
// default value of null means database 0 will be used.
|
||||||
assert.strictEqual(client.selected_db, null, "default db should be null");
|
assert.strictEqual(client.selected_db, null, "default db should be null");
|
||||||
client.SELECT(1, function (err, res) {
|
var buffering = client.SELECT(1, function (err, res) {
|
||||||
helper.isNotError()(err, res);
|
helper.isNotError()(err, res);
|
||||||
assert.strictEqual(client.selected_db, 1, "db should be 1 after select");
|
assert.strictEqual(client.selected_db, 1, "db should be 1 after select");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
assert(typeof buffering === 'boolean');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("and a callback is specified", function () {
|
describe("and a callback is specified", function () {
|
||||||
|
@@ -29,7 +29,8 @@ describe("The 'setex' method", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns an error if no value is provided', function (done) {
|
it('returns an error if no value is provided', function (done) {
|
||||||
client.SETEX(["setex key", "100", undefined], helper.isError(done));
|
var buffering = client.SETEX(["setex key", "100", undefined], helper.isError(done));
|
||||||
|
assert(typeof buffering === 'boolean');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
Reference in New Issue
Block a user