1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Minor improvement for .batch and .multi for small values

Improve the speed by round about 5% for small values

Add Multi.exec_atomic
This commit is contained in:
Ruben Bridgewater
2015-10-10 22:58:58 +02:00
parent ed2fc95444
commit f0e28bf0f7
6 changed files with 216 additions and 135 deletions

View File

@@ -17,13 +17,7 @@ describe("rename commands", function () {
describe("using " + parser + " and " + ip, function () {
var client = null;
afterEach(function () {
client.end();
});
it("allows to use renamed functions", function (done) {
if (helper.redisProcess().spawnFailed()) this.skip();
beforeEach(function(done) {
client = redis.createClient({
rename_commands: {
set: '807081f5afa96845a02816a28b7258c3',
@@ -31,6 +25,18 @@ describe("rename commands", function () {
}
});
client.on('ready', function () {
done();
});
});
afterEach(function () {
client.end();
});
it("allows to use renamed functions", function (done) {
if (helper.redisProcess().spawnFailed()) this.skip();
client.set('key', 'value', function(err, reply) {
assert.strictEqual(reply, 'OK');
});
@@ -48,16 +54,26 @@ describe("rename commands", function () {
});
});
it("should also work with multi", function (done) {
it("should also work with batch", function (done) {
if (helper.redisProcess().spawnFailed()) this.skip();
client = redis.createClient({
rename_commands: {
SET: '807081f5afa96845a02816a28b7258c3',
getrange: '9e3102b15cf231c4e9e940f284744fe0'
}
client.batch([['set', 'key', 'value']]).exec(function (err, res) {
assert.strictEqual(res[0], 'OK');
});
var batch = client.batch();
batch.getrange('key', 1, -1);
batch.exec(function (err, res) {
assert(!err);
assert.strictEqual(res.length, 1);
assert.strictEqual(res[0], 'alue');
done();
});
});
it("should also work with multi", function (done) {
if (helper.redisProcess().spawnFailed()) this.skip();
client.multi([['set', 'key', 'value']]).exec(function (err, res) {
assert.strictEqual(res[0], 'OK');
});
@@ -75,13 +91,6 @@ describe("rename commands", function () {
it("should also work with multi and abort transaction", function (done) {
if (helper.redisProcess().spawnFailed()) this.skip();
client = redis.createClient({
rename_commands: {
SET: '807081f5afa96845a02816a28b7258c3',
getrange: '9e3102b15cf231c4e9e940f284744fe0'
}
});
var multi = client.multi();
multi.get('key');
multi.getrange('key', 1, -1, function(err, reply) {