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

@@ -385,6 +385,41 @@ describe("The 'multi' method", function () {
client.get('foo', helper.isString('bar', done));
});
it("should not use a transaction with exec_atomic if only no command is used", function () {
var multi = client.multi();
var test = false;
multi.exec_batch = function () {
test = true;
};
multi.exec_atomic();
assert(test);
});
it("should not use a transaction with exec_atomic if only one command is used", function () {
var multi = client.multi();
var test = false;
multi.exec_batch = function () {
test = true;
};
multi.set("baz", "binary");
multi.exec_atomic();
assert(test);
});
it("should use transaction with exec_atomic and more than one command used", function (done) {
helper.serverVersionAtLeast.call(this, client, [2, 6, 5]);
var multi = client.multi();
var test = false;
multi.exec_batch = function () {
test = true;
};
multi.set("baz", "binary");
multi.get('baz');
multi.exec_atomic(done);
assert(!test);
});
});
});
});