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 typos / comments
This commit is contained in:
15
index.js
15
index.js
@@ -63,7 +63,7 @@ function RedisClient (options, stream) {
|
|||||||
cnx_options.family = (!options.family && net.isIP(cnx_options.host)) || (options.family === 'IPv6' ? 6 : 4);
|
cnx_options.family = (!options.family && net.isIP(cnx_options.host)) || (options.family === 'IPv6' ? 6 : 4);
|
||||||
this.address = cnx_options.host + ':' + cnx_options.port;
|
this.address = cnx_options.host + ':' + cnx_options.port;
|
||||||
}
|
}
|
||||||
/* istanbul ignore next: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
|
/* istanbul ignore next: travis does not work with stunnel atm. Therefore the tls tests are skipped on travis */
|
||||||
for (var tls_option in options.tls) { // jshint ignore: line
|
for (var tls_option in options.tls) { // jshint ignore: line
|
||||||
cnx_options[tls_option] = options.tls[tls_option];
|
cnx_options[tls_option] = options.tls[tls_option];
|
||||||
}
|
}
|
||||||
@@ -220,7 +220,7 @@ RedisClient.prototype.create_stream = function () {
|
|||||||
this.stream.destroy();
|
this.stream.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore if: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
|
/* istanbul ignore if: travis does not work with stunnel atm. Therefore the tls tests are skipped on travis */
|
||||||
if (this.options.tls) {
|
if (this.options.tls) {
|
||||||
this.stream = tls.connect(this.connection_options);
|
this.stream = tls.connect(this.connection_options);
|
||||||
} else {
|
} else {
|
||||||
@@ -230,12 +230,13 @@ RedisClient.prototype.create_stream = function () {
|
|||||||
|
|
||||||
if (this.options.connect_timeout) {
|
if (this.options.connect_timeout) {
|
||||||
this.stream.setTimeout(this.connect_timeout, function () {
|
this.stream.setTimeout(this.connect_timeout, function () {
|
||||||
|
// Note: This is only tested if a internet connection is established
|
||||||
self.retry_totaltime = self.connect_timeout;
|
self.retry_totaltime = self.connect_timeout;
|
||||||
self.connection_gone('timeout', new Error('Redis connection gone from timeout event'));
|
self.connection_gone('timeout', new Error('Redis connection gone from timeout event'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore next: travis does not work with stunnel atm. Therefor the tls tests are skipped on travis */
|
/* istanbul ignore next: travis does not work with stunnel atm. Therefore the tls tests are skipped on travis */
|
||||||
var connect_event = this.options.tls ? 'secureConnect' : 'connect';
|
var connect_event = this.options.tls ? 'secureConnect' : 'connect';
|
||||||
this.stream.once(connect_event, function () {
|
this.stream.once(connect_event, function () {
|
||||||
this.removeAllListeners('timeout');
|
this.removeAllListeners('timeout');
|
||||||
@@ -244,7 +245,7 @@ RedisClient.prototype.create_stream = function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.stream.on('data', function (buffer_from_socket) {
|
this.stream.on('data', function (buffer_from_socket) {
|
||||||
// The buffer_from_socket.toString() has a significant impact on big chunks and therefor this should only be used if necessary
|
// The buffer_from_socket.toString() has a significant impact on big chunks and therefore this should only be used if necessary
|
||||||
debug('Net read ' + self.address + ' id ' + self.connection_id); // + ': ' + buffer_from_socket.toString());
|
debug('Net read ' + self.address + ' id ' + self.connection_id); // + ': ' + buffer_from_socket.toString());
|
||||||
self.reply_parser.execute(buffer_from_socket);
|
self.reply_parser.execute(buffer_from_socket);
|
||||||
self.emit_idle();
|
self.emit_idle();
|
||||||
@@ -400,12 +401,12 @@ RedisClient.prototype.on_ready = function () {
|
|||||||
this.pub_sub_mode = this.old_state.pub_sub_mode;
|
this.pub_sub_mode = this.old_state.pub_sub_mode;
|
||||||
}
|
}
|
||||||
if (this.monitoring) { // Monitor has to be fired before pub sub commands
|
if (this.monitoring) { // Monitor has to be fired before pub sub commands
|
||||||
this.internal_send_command('monitor', []);
|
this.internal_send_command('monitor', []); // The state is still set
|
||||||
}
|
}
|
||||||
var callback_count = Object.keys(this.subscription_set).length;
|
var callback_count = Object.keys(this.subscription_set).length;
|
||||||
if (!this.options.disable_resubscribing && callback_count) {
|
if (!this.options.disable_resubscribing && callback_count) {
|
||||||
// only emit 'ready' when all subscriptions were made again
|
// only emit 'ready' when all subscriptions were made again
|
||||||
// TODO: Remove the countdown for ready here. This is not coherent with all other modes and should therefor not be handled special
|
// TODO: Remove the countdown for ready here. This is not coherent with all other modes and should therefore not be handled special
|
||||||
// We know we are ready as soon as all commands were fired
|
// We know we are ready as soon as all commands were fired
|
||||||
var callback = function () {
|
var callback = function () {
|
||||||
callback_count--;
|
callback_count--;
|
||||||
@@ -680,7 +681,7 @@ function subscribe_unsubscribe (self, reply, type, subscribe) {
|
|||||||
} else {
|
} else {
|
||||||
var running_command;
|
var running_command;
|
||||||
var i = 1;
|
var i = 1;
|
||||||
// This should be a rare case and therefor handling it this way should be good performance wise for the general case
|
// This should be a rare case and therefore handling it this way should be good performance wise for the general case
|
||||||
while (running_command = self.command_queue.get(i)) {
|
while (running_command = self.command_queue.get(i)) {
|
||||||
if (SUBSCRIBE_COMMANDS[running_command.command]) {
|
if (SUBSCRIBE_COMMANDS[running_command.command]) {
|
||||||
self.command_queue.shift();
|
self.command_queue.shift();
|
||||||
|
@@ -39,7 +39,7 @@ RedisClient.prototype.send_command = RedisClient.prototype.sendCommand = functio
|
|||||||
return this.internal_send_command(command, args, callback);
|
return this.internal_send_command(command, args, callback);
|
||||||
}
|
}
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
args = args.concat([callback]);
|
args = args.concat([callback]); // Prevent manipulating the input array
|
||||||
}
|
}
|
||||||
return this[command].apply(this, args);
|
return this[command].apply(this, args);
|
||||||
};
|
};
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
var RawObject = require('./rawObject');
|
var RawObject = require('./rawObject');
|
||||||
|
|
||||||
// hgetall converts its replies to an Object. If the reply is empty, null is returned.
|
// hgetall converts its replies to an Object. If the reply is empty, null is returned.
|
||||||
// These function are only called with internal data and have therefor always the same instanceof X
|
// These function are only called with internal data and have therefore always the same instanceof X
|
||||||
function replyToObject (reply) {
|
function replyToObject (reply) {
|
||||||
// The reply might be a string or a buffer if this is called in a transaction (multi)
|
// The reply might be a string or a buffer if this is called in a transaction (multi)
|
||||||
if (reply.length === 0 || !(reply instanceof Array)) {
|
if (reply.length === 0 || !(reply instanceof Array)) {
|
||||||
|
@@ -53,7 +53,7 @@ describe('client authentication', function () {
|
|||||||
client.auth(auth, function (err, res) {
|
client.auth(auth, function (err, res) {
|
||||||
assert.strictEqual('retry worked', res);
|
assert.strictEqual('retry worked', res);
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
// Hint: setTimeout sometimes triggers early and therefor the value can be like one or two ms to early
|
// Hint: setTimeout sometimes triggers early and therefore the value can be like one or two ms to early
|
||||||
assert(now - time >= 98, 'Time should be above 100 ms (the reconnect time) and is ' + (now - time));
|
assert(now - time >= 98, 'Time should be above 100 ms (the reconnect time) and is ' + (now - time));
|
||||||
assert(now - time < 225, 'Time should be below 255 ms (the reconnect should only take a bit above 100 ms) and is ' + (now - time));
|
assert(now - time < 225, 'Time should be below 255 ms (the reconnect should only take a bit above 100 ms) and is ' + (now - time));
|
||||||
done();
|
done();
|
||||||
|
@@ -20,7 +20,7 @@ describe('connection tests', function () {
|
|||||||
it('unofficially support for a private stream', function () {
|
it('unofficially support for a private stream', function () {
|
||||||
// While using a private stream, reconnection and other features are not going to work properly.
|
// While using a private stream, reconnection and other features are not going to work properly.
|
||||||
// Besides that some functions also have to be monkey patched to be safe from errors in this case.
|
// Besides that some functions also have to be monkey patched to be safe from errors in this case.
|
||||||
// Therefor this is not officially supported!
|
// Therefore this is not officially supported!
|
||||||
var socket = new net.Socket();
|
var socket = new net.Socket();
|
||||||
client = new redis.RedisClient({
|
client = new redis.RedisClient({
|
||||||
prefix: 'test'
|
prefix: 'test'
|
||||||
|
@@ -597,7 +597,7 @@ describe('The node_redis client', function () {
|
|||||||
assert.strictEqual(typeof rawOutput, 'string');
|
assert.strictEqual(typeof rawOutput, 'string');
|
||||||
assert(utils.monitor_regex.test(rawOutput), rawOutput);
|
assert(utils.monitor_regex.test(rawOutput), rawOutput);
|
||||||
assert.deepEqual(args, ['mget', 'hello', 'world']);
|
assert.deepEqual(args, ['mget', 'hello', 'world']);
|
||||||
// Quit immediatly ends monitoring mode and therefor does not stream back the quit command
|
// Quit immediatly ends monitoring mode and therefore does not stream back the quit command
|
||||||
monitorClient.quit(done);
|
monitorClient.quit(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -668,7 +668,7 @@ describe('The node_redis client', function () {
|
|||||||
assert.deepEqual(responses[5], ['unsubscribe', 'baz']);
|
assert.deepEqual(responses[5], ['unsubscribe', 'baz']);
|
||||||
assert.deepEqual(responses[6], ['publish', '/foo', 'hello world']);
|
assert.deepEqual(responses[6], ['publish', '/foo', 'hello world']);
|
||||||
// The publish is called right after the reconnect and the monitor is called before the message is emitted.
|
// The publish is called right after the reconnect and the monitor is called before the message is emitted.
|
||||||
// Therefor we have to wait till the next tick
|
// Therefore we have to wait till the next tick
|
||||||
process.nextTick(function () {
|
process.nextTick(function () {
|
||||||
assert(called);
|
assert(called);
|
||||||
client.quit(done);
|
client.quit(done);
|
||||||
@@ -891,7 +891,7 @@ describe('The node_redis client', function () {
|
|||||||
client.set('foo', 'bar', function (err, res) {
|
client.set('foo', 'bar', function (err, res) {
|
||||||
assert.strictEqual(err.message, 'Protocol error, got "a" as reply type byte');
|
assert.strictEqual(err.message, 'Protocol error, got "a" as reply type byte');
|
||||||
});
|
});
|
||||||
// Fail the set answer. Has no corresponding command obj and will therefor land in the error handler and set
|
// Fail the set answer. Has no corresponding command obj and will therefore land in the error handler and set
|
||||||
client.reply_parser.execute(new Buffer('a*1\r*1\r$1`zasd\r\na'));
|
client.reply_parser.execute(new Buffer('a*1\r*1\r$1`zasd\r\na'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user