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

Refactor pipelining

This commit is contained in:
Ruben Bridgewater
2016-04-14 00:57:34 +02:00
parent 5d12659583
commit 683815de9d
4 changed files with 47 additions and 54 deletions

View File

@@ -126,7 +126,7 @@ Multi.prototype.exec_transaction = function exec_transaction (callback) {
var len = self.queue.length;
self.errors = [];
self.callback = callback;
self._client.cork(len + 2);
self._client.cork();
self.wants_buffers = new Array(len);
pipeline_transaction_command(self, 'multi', []);
// Drain queue, callback will catch 'QUEUED' or error
@@ -151,7 +151,6 @@ Multi.prototype.exec_transaction = function exec_transaction (callback) {
multi_callback(self, err, replies);
});
self._client.uncork();
self._client.writeDefault = self._client.writeStrings;
return !self._client.should_buffer;
};
@@ -198,7 +197,7 @@ Multi.prototype.exec = Multi.prototype.EXEC = Multi.prototype.exec_batch = funct
return true;
}
self.results = [];
self._client.cork(len);
self._client.cork();
while (args = self.queue.shift()) {
var command = args[0];
var cb;
@@ -213,9 +212,7 @@ Multi.prototype.exec = Multi.prototype.EXEC = Multi.prototype.exec_batch = funct
self._client.internal_send_command(command, args[1], cb);
index++;
}
self.queue = new Queue();
self._client.uncork();
self._client.writeDefault = self._client.writeStrings;
return !self._client.should_buffer;
};