function Redis() { if (!(this instanceof Redis)) { return new Redis(arguments[0], arguments[1], arguments[2]); } EventEmitter.call(this); Commander.call(this); this.parseOptions(arguments[0], arguments[1], arguments[2]); this.resetCommandQueue(); this.resetOfflineQueue(); if (this.options.sentinels) { this.connector = new SentinelConnector(this.options); } else { this.connector = new Connector(this.options); } this.retryAttempts = 0; // end(or wait) -> connecting -> connect -> ready -> end if (this.options.lazyConnect) { this.setStatus('wait'); } else { this.connect().catch(_.noop); } }
n/a
function Cluster(startupNodes, options) { EventEmitter.call(this); Commander.call(this); this.options = _.defaults(this.options, options, Cluster.defaultOptions); // validate options if (typeof this.options.scaleReads !== 'function' && ['all', 'master', 'slave'].indexOf(this.options.scaleReads) === -1) { throw new Error('Invalid option scaleReads "' + this.options.scaleReads + '". Expected "all", "master", "slave" or a custom function'); } this.connectionPool = new ConnectionPool(this.options.redisOptions); this.startupNodes = startupNodes; var _this = this; this.connectionPool.on('-node', function (redis) { if (_this.status !== 'disconnecting' && _this.subscriber === redis) { _this.selectSubscriber(); } _this.emit('-node', redis); }); this.connectionPool.on('+node', function (redis) { _this.emit('+node', redis); }); this.connectionPool.on('drain', function () { _this.setStatus('close'); }); this.connectionPool.on('nodeError', function (error) { _this.emit('node error', error); }); this.slots = []; this.retryAttempts = 0; this.resetOfflineQueue(); this.delayQueue = new DelayQueue(); this.subscriber = null; if (this.options.lazyConnect) { this.setStatus('wait'); } else { this.connect().catch(_.noop); } }
...
## Cluster
Redis Cluster provides a way to run a Redis installation where data is automatically sharded across multiple Redis nodes.
You can connect to a Redis Cluster like this:
```javascript
var Redis = require('ioredis');
var cluster = new Redis.Cluster([{
port: 6380,
host: '127.0.0.1'
}, {
port: 6381,
host: '127.0.0.1'
}]);
...
function Command(name, args, options, callback) { if (typeof options === 'undefined') { options = {}; } this.name = name; this.replyEncoding = options.replyEncoding; this.errorStack = options.errorStack; this.args = args ? _.flatten(args) : []; this.callback = callback; this.initPromise(); var keyPrefix = options.keyPrefix; if (keyPrefix) { this._iterateKeys(function (key) { return keyPrefix + key; }); } }
n/a
function Promise(executor) { if (executor !== INTERNAL) { check(this, executor); } this._bitField = 0; this._fulfillmentHandler0 = undefined; this._rejectionHandler0 = undefined; this._promise0 = undefined; this._receiver0 = undefined; this._resolveFromExecutor(executor); this._promiseCreated(); this._fireEvent("promiseCreated", this); }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function OperationalError(message) { if (!(this instanceof OperationalError)) return new OperationalError(message); notEnumerableProp(this, "name", "OperationalError"); notEnumerableProp(this, "message", message); this.cause = message; this["isOperational"] = true; if (message instanceof Error) { notEnumerableProp(this, "message", message.message); notEnumerableProp(this, "stack", message.stack); } else if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } }
n/a
function PromiseInspection(promise) { if (promise !== undefined) { promise = promise._target(); this._bitField = promise._bitField; this._settledValueField = promise._isFateSealed() ? promise._settledValue() : undefined; } else { this._bitField = 0; this._settledValueField = undefined; } }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function SomePromiseArray(values) { this.constructor$(values); this._howMany = 0; this._unwrap = false; this._initialized = false; }
n/a
Promise.coroutine = function (generatorFunction, options) { if (typeof generatorFunction !== "function") { throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a"); } var yieldHandler = Object(options).yieldHandler; var PromiseSpawn$ = PromiseSpawn; var stack = new Error().stack; return function () { var generator = generatorFunction.apply(this, arguments); var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler, stack); var ret = spawn.promise(); spawn._generator = generator; spawn._promiseFulfilled(undefined); return ret; }; }
n/a
function ReplyError(message) { Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.message = message; }
n/a
function Error() { [native code] }
n/a
function Commander() { this.options = _.defaults({}, this.options || {}, { showFriendlyErrorStack: false }); this.scriptsSet = {}; }
n/a
function ConnectionPool(redisOptions) { EventEmitter.call(this); this.redisOptions = redisOptions; // master + slave = all this.nodes = { all: {}, master: {}, slave: {} }; this.specifiedOptions = {}; }
n/a
function Connector(options) { this.options = options; }
n/a
createClient = function () { return Redis.apply(this, arguments); }
n/a
function DelayQueue() { this.queues = {}; this.timeouts = {}; }
n/a
function Pipeline(redis) { Commander.call(this); this.redis = redis; this.isCluster = this.redis.constructor.name === 'Cluster'; this.options = redis.options; this._queue = []; this._result = []; this._transactions = 0; this._shaToScript = {}; var _this = this; _.keys(redis.scriptsSet).forEach(function (name) { var script = redis.scriptsSet[name]; _this._shaToScript[script.sha] = script; _this[name] = redis[name]; _this[name + 'Buffer'] = redis[name + 'Buffer']; }); this.promise = new Promise(function (resolve, reject) { _this.resolve = resolve; _this.reject = reject; }); }
...
});
```
## Pipelining
If you want to send a batch of commands (e.g. > 5), you can use pipelining to queue
the commands in memory and then send them to Redis all at once. This way the performance improves by 50%~300% (See [benchmark section
](#benchmark)).
`redis.pipeline()` creates a `Pipeline` instance. You can call any Redis
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
...
print = function (err, reply) { if (err) { console.log('Error: ' + err); } else { console.log('Reply: ' + reply); } }
n/a
function Redis() { if (!(this instanceof Redis)) { return new Redis(arguments[0], arguments[1], arguments[2]); } EventEmitter.call(this); Commander.call(this); this.parseOptions(arguments[0], arguments[1], arguments[2]); this.resetCommandQueue(); this.resetOfflineQueue(); if (this.options.sentinels) { this.connector = new SentinelConnector(this.options); } else { this.connector = new Connector(this.options); } this.retryAttempts = 0; // end(or wait) -> connecting -> connect -> ready -> end if (this.options.lazyConnect) { this.setStatus('wait'); } else { this.connect().catch(_.noop); } }
n/a
function ScanStream(opt) { Readable.call(this, opt); this._redisCursor = '0'; this.opt = opt; }
n/a
function Script(lua, numberOfKeys, keyPrefix) { this.lua = lua; this.sha = crypto.createHash('sha1').update(this.lua).digest('hex'); this.numberOfKeys = typeof numberOfKeys === 'number' ? numberOfKeys : null; this.keyPrefix = keyPrefix ? keyPrefix : ''; }
...
}
var _this = this;
if (!scripts.length) {
return execPipeline();
}
return this.redis.script('exists', scripts.map(function (item) {
return item.sha;
})).then(function (results) {
var pending = [];
for (var i = 0; i < results.length; ++i) {
if (!results[i]) {
pending.push(scripts[i]);
}
...
function SentinelConnector(options) { Connector.call(this, options); if (this.options.sentinels.length === 0) { throw new Error('Requires at least one sentinel to connect to.'); } if (!this.options.name) { throw new Error('Requires the name of master.'); } }
n/a
function SubscriptionSet() { this.set = { subscribe: {}, psubscribe: {} }; }
n/a
function EventEmitter() { EventEmitter.init.call(this); }
n/a
function Cluster(startupNodes, options) { EventEmitter.call(this); Commander.call(this); this.options = _.defaults(this.options, options, Cluster.defaultOptions); // validate options if (typeof this.options.scaleReads !== 'function' && ['all', 'master', 'slave'].indexOf(this.options.scaleReads) === -1) { throw new Error('Invalid option scaleReads "' + this.options.scaleReads + '". Expected "all", "master", "slave" or a custom function'); } this.connectionPool = new ConnectionPool(this.options.redisOptions); this.startupNodes = startupNodes; var _this = this; this.connectionPool.on('-node', function (redis) { if (_this.status !== 'disconnecting' && _this.subscriber === redis) { _this.selectSubscriber(); } _this.emit('-node', redis); }); this.connectionPool.on('+node', function (redis) { _this.emit('+node', redis); }); this.connectionPool.on('drain', function () { _this.setStatus('close'); }); this.connectionPool.on('nodeError', function (error) { _this.emit('node error', error); }); this.slots = []; this.retryAttempts = 0; this.resetOfflineQueue(); this.delayQueue = new DelayQueue(); this.subscriber = null; if (this.options.lazyConnect) { this.setStatus('wait'); } else { this.connect().catch(_.noop); } }
...
## Cluster
Redis Cluster provides a way to run a Redis installation where data is automatically sharded across multiple Redis nodes.
You can connect to a Redis Cluster like this:
```javascript
var Redis = require('ioredis');
var cluster = new Redis.Cluster([{
port: 6380,
host: '127.0.0.1'
}, {
port: 6381,
host: '127.0.0.1'
}]);
...
function EventEmitter() { EventEmitter.init.call(this); }
n/a
clusterRetryStrategy = function (times) { return Math.min(100 + times * 2, 2000); }
n/a
_handleCloseEvent = function () { var retryDelay; if (!this.manuallyClosing && typeof this.options.clusterRetryStrategy === 'function') { retryDelay = this.options.clusterRetryStrategy.call(this, ++this.retryAttempts); } if (typeof retryDelay === 'number') { this.setStatus('reconnecting'); this.reconnectTimeout = setTimeout(function () { this.reconnectTimeout = null; debug('Cluster is disconnected. Retrying after %dms', retryDelay); this.connect().catch(_.noop); }.bind(this), retryDelay); } else { this.setStatus('end'); this.flushQueue(new Error('None of startup nodes is available')); } }
...
if (this.reconnectTimeout) {
clearTimeout(this.reconnectTimeout);
this.reconnectTimeout = null;
}
if (status === 'wait') {
this.setStatus('close');
this._handleCloseEvent();
} else {
this.connectionPool.reset([]);
}
};
/**
* Quit the cluster gracefully.
...
_readyCheck = function (callback) { this.cluster('info', function (err, res) { if (err) { return callback(err); } if (typeof res !== 'string') { return callback(); } var state; var lines = res.split('\r\n'); for (var i = 0; i < lines.length; ++i) { var parts = lines[i].split(':'); if (parts[0] === 'cluster_state') { state = parts[1]; break; } } if (state === 'fail') { debug('cluster state not ok (%s)', state); callback(null, state); } else { callback(); } }); }
...
if (!info.loading || info.loading === '0') {
callback(null, info);
} else {
var retryTime = (info.loading_eta_seconds || 1) * 1000;
debug('Redis server still loading, trying again in ' + retryTime + 'ms');
setTimeout(function () {
_this._readyCheck(callback);
}, retryTime);
}
});
};
/**
* Emit only when there's at least one listener.
...
append = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
appendBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
asking = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
key = nodeKeys[0];
}
redis = _this.connectionPool.nodes.all[key];
}
}
if (asking) {
redis = _this.connectionPool.nodes.all[asking];
redis.asking();
}
}
if (!redis) {
redis = _.sample(_this.connectionPool.nodes[to]) ||
_.sample(_this.connectionPool.nodes.all);
}
}
...
askingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
auth = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
self.setStatus('connect');
self.resetCommandQueue();
// AUTH command should be processed before any other commands
var flushed = false;
if (self.condition.auth) {
self.auth(self.condition.auth, function (err) {
if (err) {
if (err.message.indexOf('no password is set') === -1) {
flushed = true;
self.flushQueue(err);
self.silentEmit('error', err);
self.disconnect(true);
} else {
...
authBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgrewriteaof = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgrewriteaofBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgsave = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgsaveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitfield = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitfieldBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitpos = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitposBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
blpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
blpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpoplpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpoplpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
call = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
var fbuffer = require('flexbuffer');
var Promise = require('bluebird');
var util = require('util');
var commands = require('redis-commands');
var calculateSlot = require('cluster-key-slot');
function Pipeline(redis) {
Commander.call(this);
this.redis = redis;
this.isCluster = this.redis.constructor.name === 'Cluster';
this.options = redis.options;
this._queue = [];
this._result = [];
this._transactions = 0;
...
callBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
client = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
return;
}
var item;
var finalSelect = self.prevCondition ? self.prevCondition.select : self.condition.select;
if (self.options.connectionName) {
debug('set the connection name [%s]', self.options.connectionName);
self.client('setname', self.options.connectionName);
}
if (self.options.readOnly) {
debug('set the connection to readonly mode');
self.readonly().catch(_.noop);
}
...
clientBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
cluster = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
};
Cluster.prototype.getInfoFromNode = function (redis, callback) {
if (!redis) {
return callback(new Error('Node is disconnected'));
}
var _this = this;
redis.cluster('slots', utils.timeout(function (err, result) {
if (err) {
redis.disconnect();
return callback(err);
}
var nodes = [];
for (var i = 0; i < result.length; ++i) {
...
clusterBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
command = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
commandBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
config = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
configBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
connect = function () { function readyHandler() { this.setStatus('ready'); this.retryAttempts = 0; this.executeOfflineCommands(); } return new Promise(function (resolve, reject) { if (this.status === 'connecting' || this.status === 'connect' || this.status === 'ready') { reject(new Error('Redis is already connecting/connected')); return; } this.setStatus('connecting'); if (!Array.isArray(this.startupNodes) || this.startupNodes.length === 0) { throw new Error('`startupNodes` should contain at least one node.'); } this.connectionPool.reset(this.startupNodes); var closeListener; var refreshListener = function () { this.removeListener('close', closeListener); this.manuallyClosing = false; this.setStatus('connect'); if (this.options.enableReadyCheck) { this._readyCheck(function (err, fail) { if (err || fail) { this.disconnect(true); } else { readyHandler.call(this); } }.bind(this)); } else { readyHandler.call(this); } resolve(); }; closeListener = function () { this.removeListener('refresh', refreshListener); reject(new Error('None of startup nodes is available')); }; this.once('refresh', refreshListener); this.once('close', closeListener); this.once('close', this._handleCloseEvent.bind(this)); this.refreshSlotsCache(function (err) { if (err && err.message === 'Failed to refresh slots cache.') { Redis.prototype.silentEmit.call(this, 'error', err); this.connectionPool.reset([]); } }.bind(this)); this.selectSubscriber(); }.bind(this)); }
...
});
```
`retryStrategy` is a function that will be called when the connection is lost.
The argument `times` means this is the nth reconnection being made and
the return value represents how long (in ms) to wait to reconnect. When the
return value isn't a number, ioredis will stop trying to reconnect, and the connection
will be lost forever if the user doesn't call `redis.connect()` manually.
When reconnected, the client will auto subscribe to channels that the previous connection subscribed to.
This behavior can be disabled by setting the `autoResubscribe` option to `false`.
And if the previous connection has some unfulfilled commands (most likely blocking commands such as `brpop` and `blpop`),
the client will resend them when reconnected. This behavior can be disabled by setting the `autoResendUnfulfilledCommands` option
to `false`.
...
createBuiltinCommand = function (commandName) { return { string: generateFunction(commandName, 'utf8'), buffer: generateFunction(commandName, null) }; }
n/a
dbsize = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
dbsizeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
debug = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
debugBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
defineCommand = function (name, definition) { var script = new Script(definition.lua, definition.numberOfKeys, this.options.keyPrefix); this.scriptsSet[name] = script; this[name] = generateScriptingFunction(script, 'utf8'); this[name + 'Buffer'] = generateScriptingFunction(script, null); }
...
care of script caching and to detect when to use `EVAL` and when to use `EVALSHA`.
ioredis expose a `defineCommand` method to make scripting much easier to use:
```javascript
var redis = new Redis();
// This will define a command echo:
redis.defineCommand('echo', {
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (err, result) {
...
del = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
`redis.pipeline()` creates a `Pipeline` instance. You can call any Redis
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
pipeline.exec(function (err, results) {
// `err` is always null, and `results` is an array of responses
// corresponding to the sequence of queued commands.
// Each response follows the format `[err, result]`.
});
// You can even chain the commands:
...
delBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
discard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
discardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
disconnect = function (reconnect) { var status = this.status; this.setStatus('disconnecting'); if (!reconnect) { this.manuallyClosing = true; } if (this.reconnectTimeout) { clearTimeout(this.reconnectTimeout); this.reconnectTimeout = null; } if (status === 'wait') { this.setStatus('close'); this._handleCloseEvent(); } else { this.connectionPool.reset([]); } }
...
});
```
You can learn more from the [Redis documentation](http://redis.io/commands/scan).
## Auto-reconnect
By default, ioredis will try to reconnect when the connection to Redis is lost
except when the connection is closed manually by `redis.disconnect()` or `redis.quit()`.
It's very flexible to control how long to wait to reconnect after disconnection
using the `retryStrategy` option:
```javascript
var redis = new Redis({
// This is the default value of `retryStrategy`
...
dump = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
dumpBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
echo = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
redis.defineCommand('echo', {
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (
err, result) {
// result === ['k1', 'k2', 'a1', 'a2']
});
// `echoBuffer` is also defined automatically to return buffers instead of strings:
redis.echoBuffer('k1', 'k2', 'a1', 'a2', function (err, result) {
// result[0] === new Buffer('k1');
});
...
echoBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (err, result) {
// result === ['k1', 'k2', 'a1', 'a2']
});
// `echoBuffer` is also defined automatically to return buffers instead of strings:
redis.echoBuffer('k1', 'k2', 'a1', 'a2', function
(err, result) {
// result[0] === new Buffer('k1');
});
// And of course it works with pipeline:
redis.pipeline().set('foo', 'bar').echo('k1', 'k2', 'a1', 'a2').exec
();
```
...
eval = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalsha = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalshaBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
exec = function (callback) { return exec.call(this).then(function (results) { if (Array.isArray(results)) { results = utils.wrapMultiResult(results); } return results; }).nodeify(callback); }
...
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
pipeline.exec(function (err, results) {
// `err` is always null, and `results` is an array of responses
// corresponding to the sequence of queued commands.
// Each response follows the format `[err, result]`.
});
// You can even chain the commands:
redis.pipeline().set('foo', 'bar').del('cc').exec(function (err, results) {
...
execBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
executeOfflineCommands = function () { if (this.offlineQueue.length) { debug('send %d commands in offline queue', this.offlineQueue.length); var offlineQueue = this.offlineQueue; this.resetOfflineQueue(); while (offlineQueue.length > 0) { var item = offlineQueue.shift(); this.sendCommand(item.command, item.stream, item.node); } } }
...
* @return {Promise}
* @public
*/
Cluster.prototype.connect = function () {
function readyHandler() {
this.setStatus('ready');
this.retryAttempts = 0;
this.executeOfflineCommands();
}
return new Promise(function (resolve, reject) {
if (this.status === 'connecting' || this.status === 'connect' || this.status === 'ready') {
reject(new Error('Redis is already connecting/connected'));
return;
}
...
exists = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
if (typeof this._keys === 'undefined') {
if (typeof transform !== 'function') {
transform = function (key) {
return key;
};
}
this._keys = [];
if (commands.exists(this.name)) {
var keyIndexes = commands.getKeyIndexes(this.name, this.args);
for (var i = 0; i < keyIndexes.length; i++) {
var index = keyIndexes[i];
this.args[index] = transform(this.args[index]);
this._keys.push(this.args[index]);
}
}
...
existsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expire = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushQueue = function (error) { var item; while (this.offlineQueue.length > 0) { item = this.offlineQueue.shift(); item.command.reject(error); } }
...
auth: this.options.password,
subscriber: false
};
var _this = this;
this.connector.connect(function (err, stream) {
if (err) {
_this.flushQueue(err);
_this.silentEmit('error', err);
reject(err);
_this.setStatus('end');
return;
}
var CONNECT_EVENT = _this.options.tls ? 'secureConnect' : 'connect';
...
flushall = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushallBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushdb = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
`Cluster#nodes()` accepts a parameter role, which can be "master", "slave" and "all" (default), and
returns an array of `Redis` instance. For example:
```javascript
// Send `FLUSHDB` command to all slaves:
var slaves = cluster.nodes('slave');
Promise.all(slaves.map(function (node) {
return node.flushdb();
}));
// Get keys of all the masters:
var masters = cluster.nodes('master');
Promise.all(masters.map(function (node) {
return node.keys();
})).then(function (keys) {
...
flushdbBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geodist = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geodistBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geohash = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geohashBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geopos = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoposBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadius = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusbymember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusbymemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
get = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
## Basic Usage
```javascript
var Redis = require('ioredis');
var redis = new Redis();
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
...
getBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
redis.set('foo', new Buffer('bar'));
```
And every command has a method that returns a Buffer (by adding a suffix of "Buffer" to the command name).
To get a buffer instead of a utf8 string:
```javascript
redis.getBuffer('foo', function (err, result) {
// result is a buffer.
});
```
## Pipelining
If you want to send a batch of commands (e.g. > 5), you can use pipelining to queue
the commands in memory and then send them to Redis all at once. This way the performance improves by 50%~300% (See [benchmark section
](#benchmark)).
...
getBuiltinCommands = function () { return _.clone(commands); }
n/a
getInfoFromNode = function (redis, callback) { if (!redis) { return callback(new Error('Node is disconnected')); } var _this = this; redis.cluster('slots', utils.timeout(function (err, result) { if (err) { redis.disconnect(); return callback(err); } var nodes = []; for (var i = 0; i < result.length; ++i) { var items = result[i]; var slotRangeStart = items[0]; var slotRangeEnd = items[1]; var keys = []; for (var j = 2; j < items.length; j++) { items[j] = { host: items[j][0], port: items[j][1] }; items[j].readOnly = j !== 2; nodes.push(items[j]); keys.push(items[j].host + ':' + items[j].port); } for (var slot = slotRangeStart; slot <= slotRangeEnd; slot++) { _this.slots[slot] = keys; } } _this.connectionPool.reset(nodes); callback(); }, 1000)); }
...
function tryNode(index) {
if (index === keys.length) {
var error = new Error('Failed to refresh slots cache.');
error.lastNodeError = lastNodeError;
return wrapper(error);
}
debug('getting slot cache from %s', keys[index]);
_this.getInfoFromNode(_this.connectionPool.nodes.all[keys[index]], function (err) {
if (_this.status === 'end') {
return wrapper(new Error('Cluster is disconnected.'));
}
if (err) {
_this.emit('node error', err);
lastNodeError = err;
tryNode(index + 1);
...
getbit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getbitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
handleError = function (error, ttl, handlers) { if (typeof ttl.value === 'undefined') { ttl.value = this.options.maxRedirections; } else { ttl.value -= 1; } if (ttl.value <= 0) { handlers.maxRedirections(new Error('Too many Cluster redirections. Last error: ' + error)); return; } var errv = error.message.split(' '); if (errv[0] === 'MOVED' || errv[0] === 'ASK') { handlers[errv[0] === 'MOVED' ? 'moved' : 'ask'](errv[1], errv[2]); } else if (errv[0] === 'TRYAGAIN') { this.delayQueue.push('tryagain', handlers.tryagain, { timeout: this.options.retryDelayOnTryAgain }); } else if (errv[0] === 'CLUSTERDOWN' && this.options.retryDelayOnClusterDown > 0) { this.delayQueue.push('clusterdown', handlers.connectionClosed, { timeout: this.options.retryDelayOnClusterDown, callback: this.refreshSlotsCache.bind(this) }); } else if (error.message === utils.CONNECTION_CLOSED_ERROR_MSG && this.options.retryDelayOnFailover > 0) { this.delayQueue.push('failover', handlers.connectionClosed, { timeout: this.options.retryDelayOnFailover, callback: this.refreshSlotsCache.bind(this) }); } else { handlers.defaults(); } }
...
var matched = true;
if (typeof this.leftRedirections === 'undefined') {
this.leftRedirections = {};
}
var exec = function () {
_this.exec();
};
this.redis.handleError(commonError, this.leftRedirections, {
moved: function (slot, key) {
_this.preferKey = key;
_this.redis.slots[errv[1]] = [key];
_this.redis.refreshSlotsCache();
_this.exec();
},
ask: function (slot, key) {
...
hdel = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hdelBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hexists = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hexistsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetall = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetallBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyfloat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyfloatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hkeys = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hkeysBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hscanBufferStream = function (key, options) { return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
hscanStream = function (key, options) { return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
...
Just like other commands, `scanStream` has a binary version `scanBufferStream`, which returns an array of buffers. It's useful
when
the key names are not utf8 strings.
There are also `hscanStream`, `zscanStream` and `sscanStream` to iterate through elements in a hash, zset and set. The interface
of each is
similar to `scanStream` except the first argument is the key name:
```javascript
var stream = redis.hscanStream('myhash', {
match: 'age:??'
});
```
You can learn more from the [Redis documentation](http://redis.io/commands/scan).
## Auto-reconnect
...
hset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hstrlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hstrlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hvals = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hvalsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyfloat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyfloatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
info = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
* process commands.
*
* @param {Function} callback
* @private
*/
Redis.prototype._readyCheck = function (callback) {
var _this = this;
this.info(function (err, res) {
if (err) {
return callback(err);
}
if (typeof res !== 'string') {
return callback(null, res);
}
...
infoBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
keys = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
Promise.all(slaves.map(function (node) {
return node.flushdb();
}));
// Get keys of all the masters:
var masters = cluster.nodes('master');
Promise.all(masters.map(function (node) {
return node.keys();
})).then(function (keys) {
// keys: [['key1', 'key2'], ['key3', 'key4']]
});
```
### Transaction and pipeline in Cluster mode
Almost all features that are supported by `Redis` are also supported by `Redis.Cluster`, e.g. custom commands, transaction and pipeline
.
...
keysBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lastsave = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lastsaveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
latency = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
latencyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lindex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lindexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
linsert = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
linsertBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
llen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
llenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ltrim = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ltrimBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
memory = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
memoryBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
migrate = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
migrateBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
module = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
moduleBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
move = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
moveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
```
There are three built-in transformers, two argument transformers for `hmset` & `mset` and
a reply transformer for `hgetall`. Transformers for `hmset` and `hgetall` were mentioned
above, and the transformer for `mset` is similar to the one for `hmset`:
```javascript
redis.mset({ k1: 'v1', k2: 'v2' });
redis.get('k1', function (err, result) {
// result === 'v1';
});
redis.mset(new Map([['k3', 'v3'], ['k4', 'v4']]));
redis.get('k3', function (err, result) {
// result === 'v3';
...
msetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
msetnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
msetnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
multi = function (commands, options) { if (typeof options === 'undefined' && !Array.isArray(commands)) { options = commands; commands = null; } if (options && options.pipeline === false) { return multi.call(this); } var pipeline = new Pipeline(this); pipeline.multi(); if (Array.isArray(commands)) { pipeline.addBatch(commands); } var exec = pipeline.exec; pipeline.exec = function (callback) { if (this._transactions > 0) { exec.call(pipeline); } var promise = exec.call(pipeline); return promise.then(function (result) { var execResult = result[result.length - 1]; if (execResult[0]) { execResult[0].previousErrors = []; for (var i = 0; i < result.length - 1; ++i) { if (result[i][0]) { execResult[0].previousErrors.push(result[i][0]); } } throw execResult[0]; } return utils.wrapMultiResult(execResult[1]); }).nodeify(callback); }; var execBuffer = pipeline.execBuffer; pipeline.execBuffer = function (callback) { if (this._transactions > 0) { execBuffer.call(pipeline); } return pipeline.exec(callback); }; return pipeline; }
...
## Transaction
Most of the time, the transaction commands `multi` & `exec` are used together with pipeline.
Therefore, when `multi` is called, a `Pipeline` instance is created automatically by default,
so you can use `multi` just like `pipeline`:
```javascript
redis.multi().set('foo', 'bar').get('foo').exec(function
(err, results) {
// results === [[null, 'OK'], [null, 'bar']]
});
```
If there's a syntax error in the transaction's command chain (e.g. wrong number of arguments, wrong command name, etc),
then none of the commands would be executed, and an error is returned:
```javascript
...
multiBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
nodes = function (role) { role = role || 'all'; if (role !== 'all' && role !== 'master' && role !== 'slave') { throw new Error('Invalid role "' + role + '". Expected "all", "master" or "slave"'); } return _.values(this.connectionPool.nodes[role]); }
...
Sometimes you may want to send a command to multiple nodes (masters or slaves) of the cluster, you can get the nodes via `Cluster
#nodes()` method.
`Cluster#nodes()` accepts a parameter role, which can be "master", "slave" and "all" (default), and
returns an array of `Redis` instance. For example:
```javascript
// Send `FLUSHDB` command to all slaves:
var slaves = cluster.nodes('slave');
Promise.all(slaves.map(function (node) {
return node.flushdb();
}));
// Get keys of all the masters:
var masters = cluster.nodes('master');
Promise.all(masters.map(function (node) {
...
object = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
objectBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
persist = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
persistBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpire = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfdebug = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfdebugBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfmerge = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfmergeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfselftest = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfselftestBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ping = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pipeline = function (commands) { var pipeline = new Pipeline(this); if (Array.isArray(commands)) { pipeline.addBatch(commands); } return pipeline; }
...
});
```
## Pipelining
If you want to send a batch of commands (e.g. > 5), you can use pipelining to queue
the commands in memory and then send them to Redis all at once. This way the performance improves by 50%~300% (See [benchmark section
](#benchmark)).
`redis.pipeline()` creates a `Pipeline` instance. You can call any Redis
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
...
post = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
postBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psetex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psetexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Both `channel` and `message` are buffers.
});
```
`PSUBSCRIBE` is also supported in a similar way:
```javascript
redis.psubscribe('pat?ern', function (err, count) {});
redis.on('pmessage', function (pattern, channel, message) {});
redis.on('pmessageBuffer', function (pattern, channel, message) {});
```
When a client issues a SUBSCRIBE or PSUBSCRIBE, that connection is put into a "subscriber" mode.
At that point, only commands that modify the subscription set are valid.
When the subscription set is empty, the connection is put back into regular mode.
...
psubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psync = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psyncBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pttl = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pttlBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
publish = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
var Redis = require('ioredis');
var redis = new Redis();
var pub = new Redis();
redis.subscribe('news', 'music', function (err, count) {
// Now we are subscribed to both the 'news' and 'music' channels.
// `count` represents the number of channels we are currently subscribed to.
pub.publish('news', 'Hello world!');
pub.publish('music', 'Hello again!');
});
redis.on('message', function (channel, message) {
// Receive message Hello world! from channel news
// Receive message Hello again! from channel music
console.log('Receive message %s from channel %s', message, channel);
...
publishBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pubsub = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pubsubBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
punsubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
punsubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
quit = function (callback) { var status = this.status; this.setStatus('disconnecting'); this.manuallyClosing = true; if (this.reconnectTimeout) { clearTimeout(this.reconnectTimeout); this.reconnectTimeout = null; } if (status === 'wait') { var ret = Promise.resolve('OK').nodeify(callback); // use setImmediate to make sure "close" event // being emitted after quit() is returned setImmediate(function () { this.setStatus('close'); this._handleCloseEvent(); }.bind(this)); return ret; } return Promise.all(this.nodes().map(function (node) { return node.quit(); })).then(function () { return 'OK'; }).nodeify(callback); }
...
});
```
You can learn more from the [Redis documentation](http://redis.io/commands/scan).
## Auto-reconnect
By default, ioredis will try to reconnect when the connection to Redis is lost
except when the connection is closed manually by `redis.disconnect()` or `redis.quit()`.
It's very flexible to control how long to wait to reconnect after disconnection
using the `retryStrategy` option:
```javascript
var redis = new Redis({
// This is the default value of `retryStrategy`
...
quitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
randomkey = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
randomkeyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readonly = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
if (self.options.connectionName) {
debug('set the connection name [%s]', self.options.connectionName);
self.client('setname', self.options.connectionName);
}
if (self.options.readOnly) {
debug('set the connection to readonly mode');
self.readonly().catch(_.noop);
}
if (self.prevCondition) {
var condition = self.prevCondition;
self.prevCondition = null;
if (condition.subscriber && self.options.autoResubscribe) {
// We re-select the previous db first since
...
readonlyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readwrite = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readwriteBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
refreshSlotsCache = function (callback) { if (this.isRefreshing) { if (typeof callback === 'function') { process.nextTick(callback); } return; } this.isRefreshing = true; var _this = this; var wrapper = function () { _this.isRefreshing = false; if (typeof callback === 'function') { callback.apply(null, arguments); } }; var keys = _.shuffle(Object.keys(this.connectionPool.nodes.all)); var lastNodeError = null; function tryNode(index) { if (index === keys.length) { var error = new Error('Failed to refresh slots cache.'); error.lastNodeError = lastNodeError; return wrapper(error); } debug('getting slot cache from %s', keys[index]); _this.getInfoFromNode(_this.connectionPool.nodes.all[keys[index]], function (err) { if (_this.status === 'end') { return wrapper(new Error('Cluster is disconnected.')); } if (err) { _this.emit('node error', err); lastNodeError = err; tryNode(index + 1); } else { _this.emit('refresh'); wrapper(); } }); } tryNode(0); }
...
var exec = function () {
_this.exec();
};
this.redis.handleError(commonError, this.leftRedirections, {
moved: function (slot, key) {
_this.preferKey = key;
_this.redis.slots[errv[1]] = [key];
_this.redis.refreshSlotsCache();
_this.exec();
},
ask: function (slot, key) {
_this.preferKey = key;
_this.exec();
},
tryagain: exec,
...
rename = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renameBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renamenx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renamenxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
replconf = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
replconfBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
resetOfflineQueue = function () { this.offlineQueue = new Deque(); }
...
EventEmitter.call(this);
Commander.call(this);
this.parseOptions(arguments[0], arguments[1], arguments[2]);
this.resetCommandQueue();
this.resetOfflineQueue();
if (this.options.sentinels) {
this.connector = new SentinelConnector(this.options);
} else {
this.connector = new Connector(this.options);
}
...
restore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restore-asking = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restore-askingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
role = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
roleBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpoplpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpoplpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
// Arguments to commands are flattened, so the following are the same:
redis.sadd('set', 1, 3, 5, 7);
redis.sadd('set', [1, 3, 5, 7]);
// All arguments are passed directly to the redis server:
redis.set('key', 100, 'EX', 10);
```
See the `examples/` folder for more examples.
...
saddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
save = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
saveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
script = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
}
var _this = this;
if (!scripts.length) {
return execPipeline();
}
return this.redis.script('exists', scripts.map(function (item) {
return item.sha;
})).then(function (results) {
var pending = [];
for (var i = 0; i < results.length; ++i) {
if (!results[i]) {
pending.push(scripts[i]);
}
...
scriptBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiff = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
select = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
console.warn('[WARN] Redis server does not require a password, but a password was supplied.');
}
}
});
}
if (self.condition.select) {
self.select(self.condition.select);
}
if (!self.options.enableReadyCheck) {
exports.readyHandler(self)();
}
self.initParser();
...
selectBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
selectSubscriber = function () { this.subscriber = _.sample(this.nodes()); if (!this.subscriber) { return; } // Re-subscribe previous channels var previousChannels = { subscribe: [], psubscribe: [] }; if (this.lastActiveSubscriber && this.lastActiveSubscriber.prevCondition) { var subscriber = this.lastActiveSubscriber.prevCondition.subscriber; if (subscriber) { previousChannels.subscribe = subscriber.channels('subscribe'); previousChannels.psubscribe = subscriber.channels('psubscribe'); } } var _this = this; if (previousChannels.subscribe.length || previousChannels.psubscribe.length) { var pending = 0; _.forEach(['subscribe', 'psubscribe'], function (type) { var channels = previousChannels[type]; if (channels.length) { pending += 1; debug('%s %d channels', type, channels.length); _this.subscriber[type](channels).then(function () { if (!--pending) { _this.lastActiveSubscriber = _this.subscriber; } }).catch(_.noop); } }); } else { if (this.subscriber.status === 'wait') { this.subscriber.connect().catch(_.noop); } this.lastActiveSubscriber = this.subscriber; } _.forEach(['message', 'messageBuffer'], function (event) { _this.subscriber.on(event, function (arg1, arg2) { _this.emit(event, arg1, arg2); }); }); _.forEach(['pmessage', 'pmessageBuffer'], function (event) { _this.subscriber.on(event, function (arg1, arg2, arg3) { _this.emit(event, arg1, arg2, arg3); }); }); }
...
this.connectionPool = new ConnectionPool(this.options.redisOptions);
this.startupNodes = startupNodes;
var _this = this;
this.connectionPool.on('-node', function (redis) {
if (_this.status !== 'disconnecting' && _this.subscriber === redis) {
_this.selectSubscriber();
}
_this.emit('-node', redis);
});
this.connectionPool.on('+node', function (redis) {
_this.emit('+node', redis);
});
this.connectionPool.on('drain', function () {
...
sendCommand = function (command, stream, node) { if (this.status === 'wait') { this.connect().catch(_.noop); } if (this.status === 'end') { command.reject(new Error(utils.CONNECTION_CLOSED_ERROR_MSG)); return command.promise; } var to = this.options.scaleReads; if (to !== 'master') { var isCommandReadOnly = commands.exists(command.name) && commands.hasFlag(command.name, 'readonly'); if (!isCommandReadOnly) { to = 'master'; } } var targetSlot = node ? node.slot : command.getSlot(); var ttl = {}; var _this = this; if (!node && !command.__is_reject_overwritten) { command.__is_reject_overwritten = true; var reject = command.reject; command.reject = function (err) { var partialTry = _.partial(tryConnection, true); _this.handleError(err, ttl, { moved: function (slot, key) { debug('command %s is moved to %s', command.name, key); if (_this.slots[slot]) { _this.slots[slot][0] = key; } else { _this.slots[slot] = [key]; } var splitKey = key.split(':'); _this.connectionPool.findOrCreate({ host: splitKey[0], port: Number(splitKey[1]) }); tryConnection(); _this.refreshSlotsCache(); }, ask: function (slot, key) { debug('command %s is required to ask %s:%s', command.name, key); var splitKey = key.split(':'); _this.connectionPool.findOrCreate({ host: splitKey[0], port: Number(splitKey[1]) }); tryConnection(false, key); }, tryagain: partialTry, clusterDown: partialTry, connectionClosed: partialTry, maxRedirections: function (redirectionError) { reject.call(command, redirectionError); }, defaults: function () { reject.call(command, err); } }); }; } tryConnection(); function tryConnection(random, asking) { if (_this.status === 'end') { command.reject(new Error('Cluster is ended.')); return; } var redis; if (_this.status === 'ready' || (command.name === 'cluster')) { if (node && node.redis) { redis = node.redis; } else if (Command.checkFlag('ENTER_SUBSCRIBER_MODE', command.name) || Command.checkFlag('EXIT_SUBSCRIBER_MODE', command.name)) { redis = _this.subscriber; } else { if (!random) { if (typeof targetSlot === 'number' && _this.slots[targetSlot]) { var nodeKeys = _this.slots[targetSlot]; if (typeof to === 'function') { var nodes = nodeKeys .map(function (key) { return _this.connectionPool.nodes.all[key]; }); redis = to(nodes, command); if (Array.isArray(redis)) { redis = utils.sample(redis); } if (!redis) { redis = nodes[0]; } } else { var key; if (to === 'all') { key = utils.sample(nodeKeys); } else if (to === 'slave' && nodeKeys.length > 1) { key = utils.sample(nodeKeys, 1); } else { key = nodeKeys[0]; } redis = _this.connectionPool.nodes.all[key]; } } if (asking) { redis = _this.connectionPool.nodes.all[asking]; redis.asking(); } } if (!redis) { redis = _.sample(_this.connectionPool.nodes[to]) || _.sample(_this.connectionPool.nodes.all); } } if (node && !node.redis) { node.redis = redis; } } if (redis) { redis.sendCommand(command, stream); } else if (_this.options.enableOfflineQueue) { _this.offlineQueue.push({ command: command, stream: stream, node: node }); } else { command.reject(new Error('Cluster isn\'t ready and enableOfflineQueue options is false')); } ...
...
if (this.options.showFriendlyErrorStack) {
options.errorStack = new Error().stack;
}
if (this.options.keyPrefix) {
options.keyPrefix = this.options.keyPrefix;
}
return this.sendCommand(new Command(commandName, args, options, callback));
};
}
function generateScriptingFunction(_script, _encoding) {
return function () {
var length = arguments.length;
var lastArgIndex = length - 1;
...
send_command = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sentinel = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
}
});
}
};
SentinelConnector.prototype.updateSentinels = function (client, callback) {
var _this = this;
client.sentinel('sentinels', this.options.name, function (err, result) {
if (err) {
client.disconnect();
return callback(err);
}
if (Array.isArray(result)) {
for (var i = 0; i < result.length; ++i) {
var sentinel = utils.packObject(result[i]);
...
sentinelBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
set = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
## Basic Usage
```javascript
var Redis = require('ioredis');
var redis = new Redis();
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
...
setBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setStatus = function (status) { debug('status: %s -> %s', this.status || '[empty]', status); this.status = status; process.nextTick(this.emit.bind(this, status)); }
...
this.connector = new Connector(this.options);
}
this.retryAttempts = 0;
// end(or wait) -> connecting -> connect -> ready -> end
if (this.options.lazyConnect) {
this.setStatus('wait');
} else {
this.connect().catch(_.noop);
}
}
util.inherits(Redis, EventEmitter);
_.assign(Redis.prototype, Commander.prototype);
...
setbit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setbitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
shutdown = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
shutdownBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinter = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sismember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sismemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slaveof = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slaveofBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slowlog = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slowlogBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smembers = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smembersBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smove = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smoveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sort = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Works well with pipelining/transaction
fooRedis.pipeline()
// Sends SORT foo:list BY foo:weight_*->fieldname
.sort('list', 'BY', 'weight_*->fieldname')
// Supports custom commands
// Sends EVALSHA xxx foo:k1 foo:k2 a1 a2
.echo('k1', 'k2', 'a1', 'a2')
.exec()
```
## Transforming Arguments & Replies
...
sortBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
spop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
spopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srandmember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srandmemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sscanBufferStream = function (key, options) { return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
sscanStream = function (key, options) { return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
strlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
strlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
subscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
It subscribes to a channel with one connection
and publishes to that channel with the other:
```javascript
var Redis = require('ioredis');
var redis = new Redis();
var pub = new Redis();
redis.subscribe('news', 'music', function (err, count) {
// Now we are subscribed to both the 'news' and 'music' channels.
// `count` represents the number of channels we are currently subscribed to.
pub.publish('news', 'Hello world!');
pub.publish('music', 'Hello again!');
});
...
subscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
substr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
substrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunion = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
swapdb = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
swapdbBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sync = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
syncBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
time = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
timeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
touch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
touchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ttl = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ttlBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
type = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
typeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unlink = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unlinkBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unsubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unsubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unwatch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unwatchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
wait = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
waitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
watch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
watchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zincrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zincrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zinterstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zinterstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zlexcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zlexcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscanBufferStream = function (key, options) { return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
zscanStream = function (key, options) { return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
zscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zunionstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zunionstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
function Command(name, args, options, callback) { if (typeof options === 'undefined') { options = {}; } this.name = name; this.replyEncoding = options.replyEncoding; this.errorStack = options.errorStack; this.args = args ? _.flatten(args) : []; this.callback = callback; this.initPromise(); var keyPrefix = options.keyPrefix; if (keyPrefix) { this._iterateKeys(function (key) { return keyPrefix + key; }); } }
n/a
checkFlag = function (flagName, commandName) { return !!flagMap[flagName][commandName]; }
...
if (this.status === 'wait') {
this.connect().catch(_.noop);
}
if (this.status === 'end') {
command.reject(new Error(utils.CONNECTION_CLOSED_ERROR_MSG));
return command.promise;
}
if (this.condition.subscriber && !Command.checkFlag('VALID_IN_SUBSCRIBER_MODE
', command.name)) {
command.reject(new Error('Connection in subscriber mode, only subscriber commands may be used'));
return command.promise;
}
var writable = (this.status === 'ready') ||
(!stream && (this.status === 'connect') && commands.hasFlag(command.name, 'loading'));
if (!this.stream) {
...
setArgumentTransformer = function (name, func) { Command._transformer.argument[name] = func; }
...
// Here's the built-in argument transformer converting
// hmset('key', { k1: 'v1', k2: 'v2' })
// or
// hmset('key', new Map([['k1', 'v1'], ['k2', 'v2']]))
// into
// hmset('key', 'k1', 'v1', 'k2', 'v2')
Redis.Command.setArgumentTransformer('hmset', function (args) {
if (args.length === 2) {
if (typeof Map !== 'undefined' && args[1] instanceof Map) {
// utils is a internal module of ioredis
return [args[0]].concat(utils.convertMapToArray(args[1]));
}
if ( typeof args[1] === 'object' && args[1] !== null) {
return [args[0]].concat(utils.convertObjectToArray(args[1]));
...
setReplyTransformer = function (name, func) { Command._transformer.reply[name] = func; }
...
return args;
});
// Here's the built-in reply transformer converting the HGETALL reply
// ['k1', 'v1', 'k2', 'v2']
// into
// { k1: 'v1', 'k2': 'v2' }
Redis.Command.setReplyTransformer('hgetall', function (result) {
if (Array.isArray(result)) {
var obj = {};
for (var i = 0; i < result.length; i += 2) {
obj[result[i]] = result[i + 1];
}
return obj;
}
...
_convertValue = function (resolve) { var _this = this; return function (value) { try { resolve(_this.transformReply(value)); } catch (err) { _this.reject(err); } return _this.promise; }; }
...
var transformer = Command._transformer.argument[_this.name];
if (transformer) {
_this.args = transformer(_this.args);
}
_this.stringifyArguments();
}
_this.resolve = _this._convertValue(resolve);
if (_this.errorStack) {
_this.reject = function (err) {
reject(utils.optimizeErrorStack(err, _this.errorStack, __dirname));
};
} else {
_this.reject = reject;
}
...
_iterateKeys = function (transform) { if (typeof this._keys === 'undefined') { if (typeof transform !== 'function') { transform = function (key) { return key; }; } this._keys = []; if (commands.exists(this.name)) { var keyIndexes = commands.getKeyIndexes(this.name, this.args); for (var i = 0; i < keyIndexes.length; i++) { var index = keyIndexes[i]; this.args[index] = transform(this.args[index]); this._keys.push(this.args[index]); } } } return this._keys; }
...
this.errorStack = options.errorStack;
this.args = args ? _.flatten(args) : [];
this.callback = callback;
this.initPromise();
var keyPrefix = options.keyPrefix;
if (keyPrefix) {
this._iterateKeys(function (key) {
return keyPrefix + key;
});
}
}
Command.prototype.initPromise = function () {
var _this = this;
...
getKeys = function () { return this._iterateKeys(); }
...
_this.reject = reject;
}
}).nodeify(this.callback);
};
Command.prototype.getSlot = function () {
if (typeof this._slot === 'undefined') {
var key = this.getKeys()[0];
if (key) {
this.slot = calculateSlot(key);
} else {
this.slot = null;
}
}
return this.slot;
...
getSlot = function () { if (typeof this._slot === 'undefined') { var key = this.getKeys()[0]; if (key) { this.slot = calculateSlot(key); } else { this.slot = null; } } return this.slot; }
...
if (to !== 'master') {
var isCommandReadOnly = commands.exists(command.name) && commands.hasFlag(command.name, 'readonly');
if (!isCommandReadOnly) {
to = 'master';
}
}
var targetSlot = node ? node.slot : command.getSlot();
var ttl = {};
var _this = this;
if (!node && !command.__is_reject_overwritten) {
command.__is_reject_overwritten = true;
var reject = command.reject;
command.reject = function (err) {
var partialTry = _.partial(tryConnection, true);
...
initPromise = function () { var _this = this; this.promise = new Promise(function (resolve, reject) { if (!_this.transformed) { _this.transformed = true; var transformer = Command._transformer.argument[_this.name]; if (transformer) { _this.args = transformer(_this.args); } _this.stringifyArguments(); } _this.resolve = _this._convertValue(resolve); if (_this.errorStack) { _this.reject = function (err) { reject(utils.optimizeErrorStack(err, _this.errorStack, __dirname)); }; } else { _this.reject = reject; } }).nodeify(this.callback); }
...
options = {};
}
this.name = name;
this.replyEncoding = options.replyEncoding;
this.errorStack = options.errorStack;
this.args = args ? _.flatten(args) : [];
this.callback = callback;
this.initPromise();
var keyPrefix = options.keyPrefix;
if (keyPrefix) {
this._iterateKeys(function (key) {
return keyPrefix + key;
});
}
...
stringifyArguments = function () { for (var i = 0; i < this.args.length; ++i) { if (!(this.args[i] instanceof Buffer) && typeof this.args[i] !== 'string') { this.args[i] = utils.toArg(this.args[i]); } } }
...
this.promise = new Promise(function (resolve, reject) {
if (!_this.transformed) {
_this.transformed = true;
var transformer = Command._transformer.argument[_this.name];
if (transformer) {
_this.args = transformer(_this.args);
}
_this.stringifyArguments();
}
_this.resolve = _this._convertValue(resolve);
if (_this.errorStack) {
_this.reject = function (err) {
reject(utils.optimizeErrorStack(err, _this.errorStack, __dirname));
};
...
toWritable = function () { var bufferMode = false; var i; for (i = 0; i < this.args.length; ++i) { if (this.args[i] instanceof Buffer) { bufferMode = true; break; } } var result, arg; var commandStr = '*' + (this.args.length + 1) + '\r\n$' + this.name.length + '\r\n' + this.name + '\r\n'; if (bufferMode) { var resultBuffer = new fbuffer.FlexBuffer(0); resultBuffer.write(commandStr); for (i = 0; i < this.args.length; ++i) { arg = this.args[i]; if (arg instanceof Buffer) { if (arg.length === 0) { resultBuffer.write('$0\r\n\r\n'); } else { resultBuffer.write('$' + arg.length + '\r\n'); resultBuffer.write(arg); resultBuffer.write('\r\n'); } } else { resultBuffer.write('$' + Buffer.byteLength(arg) + '\r\n' + arg + '\r\n'); } } result = resultBuffer.getBuffer(); } else { result = commandStr; for (i = 0; i < this.args.length; ++i) { result += '$' + Buffer.byteLength(this.args[i]) + '\r\n' + this.args[i] + '\r\n'; } } return result; }
...
this.disconnect();
command.resolve(new Buffer('OK'));
return command.promise;
}
if (writable) {
debug('write command[%d] -> %s(%s)', this.condition.select, command.name, command.args);
(stream || this.stream).write(command.toWritable());
this.commandQueue.push({
command: command,
stream: stream,
select: this.condition.select
});
...
transformReply = function (result) { if (this.replyEncoding) { result = utils.convertBufferToString(result, this.replyEncoding); } var transformer = Command._transformer.reply[this.name]; if (transformer) { result = transformer(result); } return result; }
...
* @return {function} A funtion to transform and resolve a value
* @private
*/
Command.prototype._convertValue = function (resolve) {
var _this = this;
return function (value) {
try {
resolve(_this.transformReply(value));
} catch (err) {
_this.reject(err);
}
return _this.promise;
};
};
...
function Promise(executor) { if (executor !== INTERNAL) { check(this, executor); } this._bitField = 0; this._fulfillmentHandler0 = undefined; this._rejectionHandler0 = undefined; this._promise0 = undefined; this._receiver0 = undefined; this._resolveFromExecutor(executor); this._promiseCreated(); this._fireEvent("promiseCreated", this); }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function OperationalError(message) { if (!(this instanceof OperationalError)) return new OperationalError(message); notEnumerableProp(this, "name", "OperationalError"); notEnumerableProp(this, "message", message); this.cause = message; this["isOperational"] = true; if (message instanceof Error) { notEnumerableProp(this, "message", message.message); notEnumerableProp(this, "stack", message.stack); } else if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } }
n/a
function PromiseInspection(promise) { if (promise !== undefined) { promise = promise._target(); this._bitField = promise._bitField; this._settledValueField = promise._isFateSealed() ? promise._settledValue() : undefined; } else { this._bitField = 0; this._settledValueField = undefined; } }
n/a
function RangeError() { [native code] }
n/a
function OperationalError(message) { if (!(this instanceof OperationalError)) return new OperationalError(message); notEnumerableProp(this, "name", "OperationalError"); notEnumerableProp(this, "message", message); this.cause = message; this["isOperational"] = true; if (message instanceof Error) { notEnumerableProp(this, "message", message.message); notEnumerableProp(this, "stack", message.stack); } else if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function TypeError() { [native code] }
n/a
function SomePromiseArray(values) { this.constructor$(values); this._howMany = 0; this._unwrap = false; this._initialized = false; }
n/a
_peekContext = function () {}
n/a
all = function (promises) { return new PromiseArray(promises).promise(); }
...
* **cluster:** support scaling reads to slaves ([98bdec2](https://github.com/luin/ioredis/commit/98bdec2)), closes [#170](https://
github.com/luin/ioredis/issues/170)
* **redis:** support readonly mode for cluster ([0a4186e](https://github.com/luin/ioredis/commit/0a4186e))
### BREAKING CHANGES
* **cluster:** `Cluster#masterNodes` and `Cluster#nodes` is removed. Use `Cluster#nodes('masters')` and `Cluster#nodes
('all')` instead.
* **cluster:** `Cluster#to()` is removed. Use `Promise.all(Cluster#nodes().map(function
(node) {}))` instead.
* **cluster:** Option `readOnly` is removed. Check out `scaleReads` option.
<a name="1.15.1"></a>
## [1.15.1](https://github.com/luin/ioredis/compare/v1.15.0...v1.15.1) (2016-02-19)
* select db on connect event to prevent subscribe errors ([829bf26](https://github.com/luin/ioredis/commit/829bf26)), closes [#255
](https://github.com/luin/ioredis/issues/255)
<a name="1.15.0"></a>
...
any = function (promises) { return any(promises); }
n/a
attempt = function (fn) { if (typeof fn !== "function") { return apiRejection("expecting a function but got " + util.classString(fn)); } var ret = new Promise(INTERNAL); ret._captureStackTrace(); ret._pushContext(); var value; if (arguments.length > 1) { debug.deprecated("calling Promise.try with more than 1 argument"); var arg = arguments[1]; var ctx = arguments[2]; value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg) : tryCatch(fn).call(ctx, arg); } else { value = tryCatch(fn)(); } var promiseCreated = ret._popContext(); debug.checkForgottenReturns( value, promiseCreated, "Promise.try", ret); ret._resolveFromSyncValue(value); return ret; }
n/a
bind = function (thisArg, value) { return Promise.resolve(value).bind(thisArg); }
...
address = this.stream.remoteAddress + ':' + this.stream.remotePort;
} else {
address = this.options.host + ':' + this.options.port;
}
debug('status[%s]: %s -> %s', address, this.status || '[empty]', status);
this.status = status;
process.nextTick(this.emit.bind(this, status, arg));
};
/**
* Create a connection to Redis.
* This method will be invoked automatically when creating a new Redis instance.
* @param {function} callback
* @return {Promise}
...
cast = function (obj) { var ret = tryConvertToPromise(obj); if (!(ret instanceof Promise)) { ret = new Promise(INTERNAL); ret._captureStackTrace(); ret._setFulfilled(); ret._rejectionHandler0 = obj; } return ret; }
n/a
config = function (opts) { opts = Object(opts); if ("longStackTraces" in opts) { if (opts.longStackTraces) { Promise.longStackTraces(); } else if (!opts.longStackTraces && Promise.hasLongStackTraces()) { disableLongStackTraces(); } } if ("warnings" in opts) { var warningsOption = opts.warnings; config.warnings = !!warningsOption; wForgottenReturn = config.warnings; if (util.isObject(warningsOption)) { if ("wForgottenReturn" in warningsOption) { wForgottenReturn = !!warningsOption.wForgottenReturn; } } } if ("cancellation" in opts && opts.cancellation && !config.cancellation) { if (async.haveItemsQueued()) { throw new Error( "cannot enable cancellation after promises are in use"); } Promise.prototype._clearCancellationData = cancellationClearCancellationData; Promise.prototype._propagateFrom = cancellationPropagateFrom; Promise.prototype._onCancel = cancellationOnCancel; Promise.prototype._setOnCancel = cancellationSetOnCancel; Promise.prototype._attachCancellationCallback = cancellationAttachCancellationCallback; Promise.prototype._execute = cancellationExecute; propagateFromFunction = cancellationPropagateFrom; config.cancellation = true; } if ("monitoring" in opts) { if (opts.monitoring && !config.monitoring) { config.monitoring = true; Promise.prototype._fireEvent = activeFireEvent; } else if (!opts.monitoring && config.monitoring) { config.monitoring = false; Promise.prototype._fireEvent = defaultFireEvent; } } return Promise; }
n/a
coroutine = function (generatorFunction, options) { if (typeof generatorFunction !== "function") { throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a"); } var yieldHandler = Object(options).yieldHandler; var PromiseSpawn$ = PromiseSpawn; var stack = new Error().stack; return function () { var generator = generatorFunction.apply(this, arguments); var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler, stack); var ret = spawn.promise(); spawn._generator = generator; spawn._promiseFulfilled(undefined); return ret; }; }
n/a
defer = function () { debug.deprecated("Promise.defer", "new Promise"); var promise = new Promise(INTERNAL); return { promise: promise, resolve: deferResolve, reject: deferReject }; }
n/a
delay = function (ms, value) { var ret; var handle; if (value !== undefined) { ret = Promise.resolve(value) ._then(afterValue, null, null, ms, undefined); if (debug.cancellation() && value instanceof Promise) { ret._setOnCancel(value); } } else { ret = new Promise(INTERNAL); handle = setTimeout(function() { ret._fulfill(); }, +ms); if (debug.cancellation()) { ret._setOnCancel(new HandleWrapper(handle)); } ret._captureStackTrace(); } ret._setAsyncGuaranteed(); return ret; }
n/a
each = function (promises, fn) { return PromiseReduce(promises, fn, INTERNAL, 0) ._then(promiseAllThis, undefined, undefined, promises, undefined); }
n/a
filter = function (promises, fn, options) { return PromiseMap(promises, fn, options, INTERNAL); }
n/a
fromCallback = function (fn) { var ret = new Promise(INTERNAL); ret._captureStackTrace(); var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs : false; var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs)); if (result === errorObj) { ret._rejectCallback(result.e, true); } if (!ret._isFateSealed()) ret._setAsyncGuaranteed(); return ret; }
n/a
fromNode = function (fn) { var ret = new Promise(INTERNAL); ret._captureStackTrace(); var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs : false; var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs)); if (result === errorObj) { ret._rejectCallback(result.e, true); } if (!ret._isFateSealed()) ret._setAsyncGuaranteed(); return ret; }
n/a
fulfilled = function (obj) { var ret = tryConvertToPromise(obj); if (!(ret instanceof Promise)) { ret = new Promise(INTERNAL); ret._captureStackTrace(); ret._setFulfilled(); ret._rejectionHandler0 = obj; } return ret; }
n/a
getNewLibraryCopy = function () {
var makeSelfResolutionError = function () {
return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a");
};
var reflectHandler = function() {
return new Promise.PromiseInspection(this._target());
};
var apiRejection = function(msg) {
return Promise.reject(new TypeError(msg));
};
function Proxyable() {}
var UNDEFINED_BINDING = {};
var util = require("./util");
var getDomain;
if (util.isNode) {
getDomain = function() {
var ret = process.domain;
if (ret === undefined) ret = null;
return ret;
};
} else {
getDomain = function() {
return null;
};
}
util.notEnumerableProp(Promise, "_getDomain", getDomain);
var es5 = require("./es5");
var Async = require("./async");
var async = new Async();
es5.defineProperty(Promise, "_async", {value: async});
var errors = require("./errors");
var TypeError = Promise.TypeError = errors.TypeError;
Promise.RangeError = errors.RangeError;
var CancellationError = Promise.CancellationError = errors.CancellationError;
Promise.TimeoutError = errors.TimeoutError;
Promise.OperationalError = errors.OperationalError;
Promise.RejectionError = errors.OperationalError;
Promise.AggregateError = errors.AggregateError;
var INTERNAL = function(){};
var APPLY = {};
var NEXT_FILTER = {};
var tryConvertToPromise = require("./thenables")(Promise, INTERNAL);
var PromiseArray =
require("./promise_array")(Promise, INTERNAL,
tryConvertToPromise, apiRejection, Proxyable);
var Context = require("./context")(Promise);
/*jshint unused:false*/
var createContext = Context.create;
var debug = require("./debuggability")(Promise, Context);
var CapturedTrace = debug.CapturedTrace;
var PassThroughHandlerContext =
require("./finally")(Promise, tryConvertToPromise, NEXT_FILTER);
var catchFilter = require("./catch_filter")(NEXT_FILTER);
var nodebackForPromise = require("./nodeback");
var errorObj = util.errorObj;
var tryCatch = util.tryCatch;
function check(self, executor) {
if (self == null || self.constructor !== Promise) {
throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a");
}
if (typeof executor !== "function") {
throw new TypeError("expecting a function but got " + util.classString(executor));
}
}
function Promise(executor) {
if (executor !== INTERNAL) {
check(this, executor);
}
this._bitField = 0;
this._fulfillmentHandler0 = undefined;
this._rejectionHandler0 = undefined;
this._promise0 = undefined;
this._receiver0 = undefined;
this._resolveFromExecutor(executor);
this._promiseCreated();
this._fireEvent("promiseCreated", this);
}
Promise.prototype.toString = function () {
return "[object Promise]";
};
Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
var len = arguments.length;
if (len > 1) {
var catchInstances = new Array(len - 1),
j = 0, i;
for (i = 0; i < len - 1; ++i) {
var item = arguments[i];
if (util.isObject(item)) {
catchInstances[j++] = item;
} else {
return apiRejection("Catch statement predicate: " +
"expecting an object but got " + util.classString(item));
}
}
catchInstances.length = j;
fn = arguments[i];
return this.then(undefined, catchFilter(catchInstances, fn, this));
}
return this.then(undefined, fn);
};
Promise.prototype.reflect = function () {
return this._then(reflectHandler,
reflectHandler, undefined, this, undefined);
};
Promise.prototype.then = function (didFulfill, didReject) {
if (debug.warnings() && arguments.length > 0 &&
typeof didFulfill !== "function" &&
typeof didReject !== "function") {
var msg = ".then() only accepts functions but was passed: " +
util.classString(didFulfill);
if (arguments.length > 1) {
msg += ", ...
n/a
hasLongStackTraces = function () { return config.longStackTraces && longStackTracesIsSupported(); }
n/a
is = function (val) { return val instanceof Promise; }
n/a
join = function () { var last = arguments.length - 1; var fn; if (last > 0 && typeof arguments[last] === "function") { fn = arguments[last]; if (!false) { if (last <= 8 && canEvaluate) { var ret = new Promise(INTERNAL); ret._captureStackTrace(); var HolderClass = holderClasses[last - 1]; var holder = new HolderClass(fn); var callbacks = thenCallbacks; for (var i = 0; i < last; ++i) { var maybePromise = tryConvertToPromise(arguments[i], ret); if (maybePromise instanceof Promise) { maybePromise = maybePromise._target(); var bitField = maybePromise._bitField; ; if (((bitField & 50397184) === 0)) { maybePromise._then(callbacks[i], reject, undefined, ret, holder); promiseSetters[i](maybePromise, holder); holder.asyncNeeded = false; } else if (((bitField & 33554432) !== 0)) { callbacks[i].call(ret, maybePromise._value(), holder); } else if (((bitField & 16777216) !== 0)) { ret._reject(maybePromise._reason()); } else { ret._cancel(); } } else { callbacks[i].call(ret, maybePromise, holder); } } if (!ret._isFateSealed()) { if (holder.asyncNeeded) { var domain = getDomain(); if (domain !== null) { holder.fn = util.domainBind(domain, holder.fn); } } ret._setAsyncGuaranteed(); ret._setOnCancel(holder); } return ret; } } } var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];}; if (fn) args.pop(); var ret = new PromiseArray(args).promise(); return fn !== undefined ? ret.spread(fn) : ret; }
n/a
longStackTraces = function () { if (async.haveItemsQueued() && !config.longStackTraces) { throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a"); } if (!config.longStackTraces && longStackTracesIsSupported()) { var Promise_captureStackTrace = Promise.prototype._captureStackTrace; var Promise_attachExtraTrace = Promise.prototype._attachExtraTrace; config.longStackTraces = true; disableLongStackTraces = function() { if (async.haveItemsQueued() && !config.longStackTraces) { throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo. gl/MqrFmX\u000a"); } Promise.prototype._captureStackTrace = Promise_captureStackTrace; Promise.prototype._attachExtraTrace = Promise_attachExtraTrace; Context.deactivateLongStackTraces(); async.enableTrampoline(); config.longStackTraces = false; }; Promise.prototype._captureStackTrace = longStackTracesCaptureStackTrace; Promise.prototype._attachExtraTrace = longStackTracesAttachExtraTrace; Context.activateLongStackTraces(); async.disableTrampolineIfNecessary(); } }
n/a
map = function (promises, fn, options, _filter) { return map(promises, fn, options, _filter); }
...
* **cluster:** support scaling reads to slaves ([98bdec2](https://github.com/luin/ioredis/commit/98bdec2)), closes [#170](https://
github.com/luin/ioredis/issues/170)
* **redis:** support readonly mode for cluster ([0a4186e](https://github.com/luin/ioredis/commit/0a4186e))
### BREAKING CHANGES
* **cluster:** `Cluster#masterNodes` and `Cluster#nodes` is removed. Use `Cluster#nodes('masters')` and `Cluster#nodes
('all')` instead.
* **cluster:** `Cluster#to()` is removed. Use `Promise.all(Cluster#nodes().map(function
(node) {}))` instead.
* **cluster:** Option `readOnly` is removed. Check out `scaleReads` option.
<a name="1.15.1"></a>
## [1.15.1](https://github.com/luin/ioredis/compare/v1.15.0...v1.15.1) (2016-02-19)
* select db on connect event to prevent subscribe errors ([829bf26](https://github.com/luin/ioredis/commit/829bf26)), closes [#255
](https://github.com/luin/ioredis/issues/255)
<a name="1.15.0"></a>
...
function PromiseMapSeries(promises, fn) { return PromiseReduce(promises, fn, INTERNAL, INTERNAL); }
n/a
method = function (fn) { if (typeof fn !== "function") { throw new Promise.TypeError("expecting a function but got " + util.classString(fn)); } return function () { var ret = new Promise(INTERNAL); ret._captureStackTrace(); ret._pushContext(); var value = tryCatch(fn).apply(this, arguments); var promiseCreated = ret._popContext(); debug.checkForgottenReturns( value, promiseCreated, "Promise.method", ret); ret._resolveFromSyncValue(value); return ret; }; }
n/a
function noConflict() { try { if (Promise === bluebird) Promise = old; } catch (e) {} return bluebird; }
n/a
onPossiblyUnhandledRejection = function (fn) { var domain = getDomain(); possiblyUnhandledRejection = typeof fn === "function" ? (domain === null ? fn : util.domainBind(domain, fn)) : undefined; }
...
However, it would decrease the performance significantly to optimize the error stack. So by
default, this option is disabled and can only be used for debugging purposes. You **shouldn't** use this feature in a production
environment.
If you want to catch all unhandled errors without decreased performance, there's another way:
```javascript
var Redis = require('ioredis');
Redis.Promise.onPossiblyUnhandledRejection(function (error) {
// you can log the error here.
// error.command.name is the command name, here is 'set'
// error.command.args is the command arguments, here is ['foo']
});
var redis = new Redis();
redis.set('foo');
```
...
onUnhandledRejectionHandled = function (fn) { var domain = getDomain(); unhandledRejectionHandled = typeof fn === "function" ? (domain === null ? fn : util.domainBind(domain, fn)) : undefined; }
n/a
pending = function () { debug.deprecated("Promise.defer", "new Promise"); var promise = new Promise(INTERNAL); return { promise: promise, resolve: deferResolve, reject: deferReject }; }
n/a
promisify = function (fn, options) { if (typeof fn !== "function") { throw new TypeError("expecting a function but got " + util.classString(fn)); } if (isPromisified(fn)) { return fn; } options = Object(options); var receiver = options.context === undefined ? THIS : options.context; var multiArgs = !!options.multiArgs; var ret = promisify(fn, receiver, multiArgs); util.copyDescriptors(fn, ret, propsFilter); return ret; }
n/a
promisifyAll = function (target, options) { if (typeof target !== "function" && typeof target !== "object") { throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/MqrFmX\ u000a"); } options = Object(options); var multiArgs = !!options.multiArgs; var suffix = options.suffix; if (typeof suffix !== "string") suffix = defaultSuffix; var filter = options.filter; if (typeof filter !== "function") filter = defaultFilter; var promisifier = options.promisifier; if (typeof promisifier !== "function") promisifier = makeNodePromisified; if (!util.isIdentifier(suffix)) { throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/MqrFmX\u000a"); } var keys = util.inheritedDataKeys(target); for (var i = 0; i < keys.length; ++i) { var value = target[keys[i]]; if (keys[i] !== "constructor" && util.isClass(value)) { promisifyAll(value.prototype, suffix, filter, promisifier, multiArgs); promisifyAll(value, suffix, filter, promisifier, multiArgs); } } return promisifyAll(target, suffix, filter, promisifier, multiArgs); }
n/a
props = function (promises) { return props(promises); }
n/a
race = function (promises) { return race(promises, undefined); }
n/a
reduce = function (promises, fn, initialValue, _each) { return reduce(promises, fn, initialValue, _each); }
...
ENTER_SUBSCRIBER_MODE: ['subscribe', 'psubscribe'],
// Commands that may make current connection quit subscriber mode
EXIT_SUBSCRIBER_MODE: ['unsubscribe', 'punsubscribe'],
// Commands that will make client disconnect from server TODO shutdown?
WILL_DISCONNECT: ['quit']
};
var flagMap = Object.keys(Command.FLAGS).reduce(function (map, flagName) {
map[flagName] = {};
Command.FLAGS[flagName].forEach(function (commandName) {
map[flagName][commandName] = true;
});
return map;
}, {});
...
reject = function (reason) { var ret = new Promise(INTERNAL); ret._captureStackTrace(); ret._rejectCallback(reason, true); return ret; }
...
for (var i = firstArgIndex; i < length; ++i) {
args[i - firstArgIndex] = arguments[i];
}
var options;
if (this.options.dropBufferSupport) {
if (!_encoding) {
return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback);
}
options = { replyEncoding: null };
} else {
options = { replyEncoding: _encoding };
}
if (this.options.showFriendlyErrorStack) {
...
rejected = function (reason) { var ret = new Promise(INTERNAL); ret._captureStackTrace(); ret._rejectCallback(reason, true); return ret; }
n/a
resolve = function (obj) { var ret = tryConvertToPromise(obj); if (!(ret instanceof Promise)) { ret = new Promise(INTERNAL); ret._captureStackTrace(); ret._setFulfilled(); ret._rejectionHandler0 = obj; } return ret; }
...
var ignoredCount = 0;
for (i = 0; i < this._queue.length - ignoredCount; ++i) {
if (this._queue[i + ignoredCount].ignore) {
ignoredCount += 1;
}
this._result[i] = this._result[i + ignoredCount];
}
this.resolve(this._result.slice(0, this._result.length - ignoredCount));
};
Pipeline.prototype.sendCommand = function (command) {
var position = this._queue.length;
var _this = this;
...
setScheduler = function (fn) { if (typeof fn !== "function") { throw new TypeError("expecting a function but got " + util.classString(fn)); } return async.setScheduler(fn); }
n/a
settle = function (promises) { debug.deprecated(".settle()", ".reflect()"); return new SettledPromiseArray(promises).promise(); }
n/a
some = function (promises, howMany) { return some(promises, howMany); }
...
}
if (Array.isArray(result)) {
for (var i = 0; i < result.length; ++i) {
var sentinel = utils.packObject(result[i]);
var flags = sentinel.flags ? sentinel.flags.split(',') : [];
if (flags.indexOf('disconnected') === -1 && sentinel.ip && sentinel.port) {
var endpoint = { host: sentinel.ip, port: parseInt(sentinel.port, 10) };
var isDuplicate = _this.sentinels.some(_.bind(isSentinelEql, null, endpoint));
if (!isDuplicate) {
debug('adding sentinel %s:%s', endpoint.host, endpoint.port);
_this.sentinels.push(endpoint);
}
}
}
debug('sentinels', _this.sentinels);
...
spawn = function (generatorFunction) { debug.deprecated("Promise.spawn()", "Promise.coroutine()"); if (typeof generatorFunction !== "function") { return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a"); } var spawn = new PromiseSpawn(generatorFunction, this); var ret = spawn.promise(); spawn._run(Promise.spawn); return ret; }
n/a
try = function (fn) { if (typeof fn !== "function") { return apiRejection("expecting a function but got " + util.classString(fn)); } var ret = new Promise(INTERNAL); ret._captureStackTrace(); ret._pushContext(); var value; if (arguments.length > 1) { debug.deprecated("calling Promise.try with more than 1 argument"); var arg = arguments[1]; var ctx = arguments[2]; value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg) : tryCatch(fn).call(ctx, arg); } else { value = tryCatch(fn)(); } var promiseCreated = ret._popContext(); debug.checkForgottenReturns( value, promiseCreated, "Promise.try", ret); ret._resolveFromSyncValue(value); return ret; }
n/a
using = function () { var len = arguments.length; if (len < 2) return apiRejection( "you must pass at least 2 arguments to Promise.using"); var fn = arguments[len - 1]; if (typeof fn !== "function") { return apiRejection("expecting a function but got " + util.classString(fn)); } var input; var spreadArgs = true; if (len === 2 && Array.isArray(arguments[0])) { input = arguments[0]; len = input.length; spreadArgs = false; } else { input = arguments; len--; } var resources = new ResourceList(len); for (var i = 0; i < len; ++i) { var resource = input[i]; if (Disposer.isDisposer(resource)) { var disposer = resource; resource = resource.promise(); resource._setDisposable(disposer); } else { var maybePromise = tryConvertToPromise(resource); if (maybePromise instanceof Promise) { resource = maybePromise._then(maybeUnwrapDisposer, null, null, { resources: resources, index: i }, undefined); } } resources[i] = resource; } var reflectedResources = new Array(resources.length); for (var i = 0; i < reflectedResources.length; ++i) { reflectedResources[i] = Promise.resolve(resources[i]).reflect(); } var resultPromise = Promise.all(reflectedResources) .then(function(inspections) { for (var i = 0; i < inspections.length; ++i) { var inspection = inspections[i]; if (inspection.isRejected()) { errorObj.e = inspection.error(); return errorObj; } else if (!inspection.isFulfilled()) { resultPromise.cancel(); return; } inspections[i] = inspection.value(); } promise._pushContext(); fn = tryCatch(fn); var ret = spreadArgs ? fn.apply(undefined, inspections) : fn(inspections); var promiseCreated = promise._popContext(); debug.checkForgottenReturns( ret, promiseCreated, "Promise.using", promise); return ret; }); var promise = resultPromise.lastly(function() { var inspection = new Promise.PromiseInspection(resultPromise); return dispose(resources, inspection); }); resources.promise = promise; promise._setOnCancel(resources); return promise; }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function every() { [native code] }
n/a
function filter() { [native code] }
n/a
function forEach() { [native code] }
...
Commander.prototype.createBuiltinCommand = function (commandName) {
return {
string: generateFunction(commandName, 'utf8'),
buffer: generateFunction(commandName, null)
};
};
_.forEach(commands, function (commandName) {
Commander.prototype[commandName] = generateFunction(commandName, 'utf8');
Commander.prototype[commandName + 'Buffer'] = generateFunction(commandName, null);
});
Commander.prototype.call = generateFunction('utf8');
Commander.prototype.callBuffer = generateFunction(null);
Commander.prototype.send_command = Commander.prototype.call;
...
function indexOf() { [native code] }
...
var evalsha = new Command('evalsha', [this.sha].concat(args), options);
evalsha.isCustomCommand = true;
var result = container.sendCommand(evalsha);
if (result instanceof Promise) {
var _this = this;
return result.catch(function (err) {
if (err.toString().indexOf('NOSCRIPT') === -1) {
throw err;
}
return container.sendCommand(new Command('eval', [_this.lua].concat(args), options));
}).nodeify(callback);
}
// result is not a Promise--probably returned from a pipeline chain; however,
...
function join() { [native code] }
n/a
function lastIndexOf() { [native code] }
n/a
function map() { [native code] }
...
* **cluster:** support scaling reads to slaves ([98bdec2](https://github.com/luin/ioredis/commit/98bdec2)), closes [#170](https://
github.com/luin/ioredis/issues/170)
* **redis:** support readonly mode for cluster ([0a4186e](https://github.com/luin/ioredis/commit/0a4186e))
### BREAKING CHANGES
* **cluster:** `Cluster#masterNodes` and `Cluster#nodes` is removed. Use `Cluster#nodes('masters')` and `Cluster#nodes
('all')` instead.
* **cluster:** `Cluster#to()` is removed. Use `Promise.all(Cluster#nodes().map(function
(node) {}))` instead.
* **cluster:** Option `readOnly` is removed. Check out `scaleReads` option.
<a name="1.15.1"></a>
## [1.15.1](https://github.com/luin/ioredis/compare/v1.15.0...v1.15.1) (2016-02-19)
* select db on connect event to prevent subscribe errors ([829bf26](https://github.com/luin/ioredis/commit/829bf26)), closes [#255
](https://github.com/luin/ioredis/issues/255)
<a name="1.15.0"></a>
...
function pop() { [native code] }
n/a
function push() { [native code] }
...
var redis = new Redis();
// Create a readable stream (object mode)
var stream = redis.scanStream();
var keys = [];
stream.on('data', function (resultKeys) {
// `resultKeys` is an array of strings representing key names
for (var i = 0; i < resultKeys.length; i++) {
keys.push(resultKeys[i]);
}
});
stream.on('end', function () {
console.log('done with the keys: ', keys);
});
```
...
function reduce() { [native code] }
...
ENTER_SUBSCRIBER_MODE: ['subscribe', 'psubscribe'],
// Commands that may make current connection quit subscriber mode
EXIT_SUBSCRIBER_MODE: ['unsubscribe', 'punsubscribe'],
// Commands that will make client disconnect from server TODO shutdown?
WILL_DISCONNECT: ['quit']
};
var flagMap = Object.keys(Command.FLAGS).reduce(function (map, flagName) {
map[flagName] = {};
Command.FLAGS[flagName].forEach(function (commandName) {
map[flagName][commandName] = true;
});
return map;
}, {});
...
function reduceRight() { [native code] }
n/a
function reverse() { [native code] }
n/a
function shift() { [native code] }
...
return this;
};
Pipeline.prototype.addBatch = function (commands) {
for (var i = 0; i < commands.length; ++i) {
var command = commands[i];
var commandName = command.shift();
this[commandName].apply(this, command);
}
return this;
};
var multi = Pipeline.prototype.multi;
...
function slice() { [native code] }
...
Besides auto-reconnect when the connection is closed, ioredis supports reconnecting on the specified errors by the `reconnectOnError
` option. Here's an example that will reconnect when receiving `READONLY` error:
```javascript
var redis = new Redis({
reconnectOnError: function (err) {
var targetError = 'READONLY';
if (err.message.slice(0, targetError.length) === targetError) {
// Only reconnect when the error starts with "READONLY"
return true; // or `return 1;`
}
}
});
```
...
function some() { [native code] }
...
}
if (Array.isArray(result)) {
for (var i = 0; i < result.length; ++i) {
var sentinel = utils.packObject(result[i]);
var flags = sentinel.flags ? sentinel.flags.split(',') : [];
if (flags.indexOf('disconnected') === -1 && sentinel.ip && sentinel.port) {
var endpoint = { host: sentinel.ip, port: parseInt(sentinel.port, 10) };
var isDuplicate = _this.sentinels.some(_.bind(isSentinelEql, null, endpoint));
if (!isDuplicate) {
debug('adding sentinel %s:%s', endpoint.host, endpoint.port);
_this.sentinels.push(endpoint);
}
}
}
debug('sentinels', _this.sentinels);
...
function sort() { [native code] }
...
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Works well with pipelining/transaction
fooRedis.pipeline()
// Sends SORT foo:list BY foo:weight_*->fieldname
.sort('list', 'BY', 'weight_*->fieldname')
// Supports custom commands
// Sends EVALSHA xxx foo:k1 foo:k2 a1 a2
.echo('k1', 'k2', 'a1', 'a2')
.exec()
```
## Transforming Arguments & Replies
...
toString = function () { var indent = Array(level * 4 + 1).join(" "); var ret = "\n" + indent + "AggregateError of:" + "\n"; level++; indent = Array(level * 4 + 1).join(" "); for (var i = 0; i < this.length; ++i) { var str = this[i] === this ? "[Circular AggregateError]" : this[i] + ""; var lines = str.split("\n"); for (var j = 0; j < lines.length; ++j) { lines[j] = indent + lines[j]; } str = lines.join("\n"); ret += str + "\n"; } level--; return ret; }
...
}
var _this = this;
this.opt.redis[this.opt.command](args, function (err, res) {
if (err) {
_this.emit('error', err);
return;
}
_this._redisCursor = (res[0] instanceof Buffer) ? res[0].toString() : res[0];
if (_this._redisCursor === '0') {
_this._redisDrained = true;
}
_this.push(res[1]);
});
};
...
function unshift() { [native code] }
...
ScanStream.prototype._read = function () {
if (this._redisDrained) {
this.push(null);
return;
}
var args = [this._redisCursor];
if (this.opt.key) {
args.unshift(this.opt.key);
}
if (this.opt.match) {
args.push('MATCH', this.opt.match);
}
if (this.opt.count) {
args.push('COUNT', this.opt.count);
}
...
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function OperationalError(message) { if (!(this instanceof OperationalError)) return new OperationalError(message); notEnumerableProp(this, "name", "OperationalError"); notEnumerableProp(this, "message", message); this.cause = message; this["isOperational"] = true; if (message instanceof Error) { notEnumerableProp(this, "message", message.message); notEnumerableProp(this, "stack", message.stack); } else if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } }
n/a
function OperationalError(message) { if (!(this instanceof OperationalError)) return new OperationalError(message); notEnumerableProp(this, "name", "OperationalError"); notEnumerableProp(this, "message", message); this.cause = message; this["isOperational"] = true; if (message instanceof Error) { notEnumerableProp(this, "message", message.message); notEnumerableProp(this, "stack", message.stack); } else if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } }
n/a
function PromiseInspection(promise) { if (promise !== undefined) { promise = promise._target(); this._bitField = promise._bitField; this._settledValueField = promise._isFateSealed() ? promise._settledValue() : undefined; } else { this._bitField = 0; this._settledValueField = undefined; } }
n/a
_settledValue = function () { return this._settledValueField; }
n/a
error = function () { if (!this.isRejected()) { throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/MqrFmX\u000a "); } return this._settledValue(); }
...
}
}
}
if (this.listeners(eventName).length > 0) {
return this.emit.apply(this, arguments);
}
if (error && error instanceof Error) {
console.error('[ioredis] Unhandled error event:', error.stack);
}
return false;
};
/**
* Listen for all requests received by the server in real time.
*
...
isCancelled = function () { return (this._bitField & 8454144) !== 0; }
n/a
isFulfilled = function () { return (this._bitField & 33554432) !== 0; }
n/a
isPending = function () { return (this._bitField & 50397184) === 0; }
n/a
isRejected = function () { return (this._bitField & 16777216) !== 0; }
n/a
isResolved = function () { return (this._bitField & 50331648) !== 0; }
n/a
reason = function () { if (!this.isRejected()) { throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/MqrFmX\u000a "); } return this._settledValue(); }
n/a
value = function () { if (!this.isFulfilled()) { throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/MqrFmX\u000a "); } return this._settledValue(); }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function SubError(message) { if (!(this instanceof SubError)) return new SubError(message); notEnumerableProp(this, "message", typeof message === "string" ? message : defaultMessage); notEnumerableProp(this, "name", nameProperty); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } else { Error.call(this); } }
n/a
function SomePromiseArray(values) { this.constructor$(values); this._howMany = 0; this._unwrap = false; this._initialized = false; }
n/a
_addFulfilled = function (value) { this._values[this._totalResolved++] = value; }
n/a
_addRejected = function (reason) { this._values.push(reason); }
n/a
_canPossiblyFulfill = function () { return this.length() - this._rejected(); }
n/a
_checkOutcome = function () { if (this.howMany() > this._canPossiblyFulfill()) { var e = new AggregateError(); for (var i = this.length(); i < this._values.length; ++i) { if (this._values[i] !== CANCELLATION) { e.push(this._values[i]); } } if (e.length > 0) { this._reject(e); } else { this._cancel(); } return true; } return false; }
n/a
_fulfilled = function () { return this._totalResolved; }
n/a
_getRangeError = function (count) { var message = "Input array must contain at least " + this._howMany + " items but contains only " + count + " items"; return new RangeError(message); }
n/a
_init = function () { if (!this._initialized) { return; } if (this._howMany === 0) { this._resolve([]); return; } this._init$(undefined, -5); var isArrayResolved = isArray(this._values); if (!this._isResolved() && isArrayResolved && this._howMany > this._canPossiblyFulfill()) { this._reject(this._getRangeError(this.length())); } }
n/a
_promiseCancelled = function () { if (this._values instanceof Promise || this._values == null) { return this._cancel(); } this._addRejected(CANCELLATION); return this._checkOutcome(); }
n/a
_promiseFulfilled = function (value) { this._addFulfilled(value); if (this._fulfilled() === this.howMany()) { this._values.length = this.howMany(); if (this.howMany() === 1 && this._unwrap) { this._resolve(this._values[0]); } else { this._resolve(this._values); } return true; } return false; }
n/a
_promiseRejected = function (reason) { this._addRejected(reason); return this._checkOutcome(); }
n/a
_rejected = function () { return this._values.length - this.length(); }
n/a
_resolveEmptyArray = function () { this._reject(this._getRangeError(0)); }
n/a
function SomePromiseArray(values) { this.constructor$(values); this._howMany = 0; this._unwrap = false; this._initialized = false; }
n/a
howMany = function () { return this._howMany; }
n/a
init = function () { this._initialized = true; this._init(); }
n/a
setHowMany = function (count) { this._howMany = count; }
n/a
setUnwrap = function () { this._unwrap = true; }
n/a
coroutine = function (generatorFunction, options) { if (typeof generatorFunction !== "function") { throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a"); } var yieldHandler = Object(options).yieldHandler; var PromiseSpawn$ = PromiseSpawn; var stack = new Error().stack; return function () { var generator = generatorFunction.apply(this, arguments); var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler, stack); var ret = spawn.promise(); spawn._generator = generator; spawn._promiseFulfilled(undefined); return ret; }; }
n/a
addYieldHandler = function (fn) { if (typeof fn !== "function") { throw new TypeError("expecting a function but got " + util.classString(fn)); } yieldHandlers.push(fn); }
n/a
__isCancelled = function () { return (this._bitField & 65536) === 65536; }
n/a
_addCallbacks = function ( fulfill, reject, promise, receiver, domain ) { var index = this._length(); if (index >= 65535 - 4) { index = 0; this._setLength(0); } if (index === 0) { this._promise0 = promise; this._receiver0 = receiver; if (typeof fulfill === "function") { this._fulfillmentHandler0 = domain === null ? fulfill : util.domainBind(domain, fulfill); } if (typeof reject === "function") { this._rejectionHandler0 = domain === null ? reject : util.domainBind(domain, reject); } } else { var base = index * 4 - 4; this[base + 2] = promise; this[base + 3] = receiver; if (typeof fulfill === "function") { this[base + 0] = domain === null ? fulfill : util.domainBind(domain, fulfill); } if (typeof reject === "function") { this[base + 1] = domain === null ? reject : util.domainBind(domain, reject); } } this._setLength(index + 1); return index; }
n/a
_attachCancellationCallback = function (onCancel) { ; }
n/a
_attachExtraTrace = function () {}
n/a
_boundValue = function () {}
n/a
_branchHasCancelled = function () { this._branchesRemainingToCancel--; }
n/a
_cancel = function () { if (!this._isCancellable()) return; this._setCancelled(); async.invoke(this._cancelPromises, this, undefined); }
n/a
_cancelBranched = function () { if (this._enoughBranchesHaveCancelled()) { this._cancel(); } }
n/a
_cancelBy = function (canceller) { if (canceller === this) { this._branchesRemainingToCancel = 0; this._invokeOnCancel(); return true; } else { this._branchHasCancelled(); if (this._enoughBranchesHaveCancelled()) { this._invokeOnCancel(); return true; } } return false; }
n/a
_cancelPromises = function () { if (this._length() > 0) this._settlePromises(); }
n/a
_captureStackTrace = function () {}
n/a
_clearCallbackDataAtIndex = function (index) { var base = index * 4 - 4; this[base + 2] = this[base + 3] = this[base + 0] = this[base + 1] = undefined; }
n/a
_clearCancellationData = function () {}
n/a
_doInvokeOnCancel = function (onCancelCallback, internalOnly) { if (util.isArray(onCancelCallback)) { for (var i = 0; i < onCancelCallback.length; ++i) { this._doInvokeOnCancel(onCancelCallback[i], internalOnly); } } else if (onCancelCallback !== undefined) { if (typeof onCancelCallback === "function") { if (!internalOnly) { var e = tryCatch(onCancelCallback).call(this._boundValue()); if (e === errorObj) { this._attachExtraTrace(e.e); async.throwLater(e.e); } } } else { onCancelCallback._resultCancelled(this); } } }
n/a
_enoughBranchesHaveCancelled = function () { return this._branchesRemainingToCancel === undefined || this._branchesRemainingToCancel <= 0; }
n/a
_ensurePossibleRejectionHandled = function () { if ((this._bitField & 524288) !== 0) return; this._setRejectionIsUnhandled(); async.invokeLater(this._notifyUnhandledRejection, this, undefined); }
n/a
_execute = function (executor, resolve, reject) { try { executor(resolve, reject); } catch (e) { return e; } }
...
queue.push(item);
if (!this.timeouts[bucket]) {
var _this = this;
this.timeouts[bucket] = setTimeout(function () {
callback(function () {
_this.timeouts[bucket] = null;
_this._execute(bucket);
});
}, options.timeout);
}
};
DelayQueue.prototype._execute = function (bucket) {
var queue = this.queues[bucket];
...
function defaultFireEvent() { return false; }
n/a
_followee = function () { return this._rejectionHandler0; }
n/a
_fulfill = function (value) { var bitField = this._bitField; if (((bitField & 117506048) >>> 16)) return; if (value === this) { var err = makeSelfResolutionError(); this._attachExtraTrace(err); return this._reject(err); } this._setFulfilled(); this._rejectionHandler0 = value; if ((bitField & 65535) > 0) { if (((bitField & 134217728) !== 0)) { this._settlePromises(); } else { async.settlePromises(this); } } }
n/a
_fulfillPromises = function (len, value) { for (var i = 1; i < len; i++) { var handler = this._fulfillmentHandlerAt(i); var promise = this._promiseAt(i); var receiver = this._receiverAt(i); this._clearCallbackDataAtIndex(i); this._settlePromise(promise, handler, receiver, value); } }
n/a
_fulfillmentHandlerAt = function (index) { return this[ index * 4 - 4 + 0]; }
n/a
_getDisposer = function () { return this._disposer; }
n/a
_invokeInternalOnCancel = function () { if (this._isCancellable()) { this._doInvokeOnCancel(this._onCancel(), true); this._unsetOnCancel(); } }
n/a
_invokeOnCancel = function () { var onCancelCallback = this._onCancel(); this._unsetOnCancel(); async.invoke(this._doInvokeOnCancel, this, onCancelCallback); }
n/a
_isBound = function () { return (this._bitField & 2097152) === 2097152; }
n/a
_isCancellable = function () { return this.isPending() && !this._isCancelled(); }
n/a
_isCancelled = function () { return this._target().__isCancelled(); }
n/a
_isDisposable = function () { return (this._bitField & 131072) > 0; }
n/a
_isFateSealed = function () { return (this._bitField & 117506048) !== 0; }
n/a
_isFinal = function () { return (this._bitField & 4194304) > 0; }
n/a
_isFollowing = function () { return (this._bitField & 67108864) === 67108864; }
n/a
_isRejectionUnhandled = function () { return (this._bitField & 1048576) > 0; }
n/a
_isUnhandledRejectionNotified = function () { return (this._bitField & 262144) > 0; }
n/a
_length = function () { return this._bitField & 65535; }
n/a
_migrateCallback0 = function (follower) { var bitField = follower._bitField; var fulfill = follower._fulfillmentHandler0; var reject = follower._rejectionHandler0; var promise = follower._promise0; var receiver = follower._receiverAt(0); if (receiver === undefined) receiver = UNDEFINED_BINDING; this._addCallbacks(fulfill, reject, promise, receiver, null); }
n/a
_migrateCallbackAt = function (follower, index) { var fulfill = follower._fulfillmentHandlerAt(index); var reject = follower._rejectionHandlerAt(index); var promise = follower._promiseAt(index); var receiver = follower._receiverAt(index); if (receiver === undefined) receiver = UNDEFINED_BINDING; this._addCallbacks(fulfill, reject, promise, receiver, null); }
n/a
_notifyUnhandledRejection = function () { if (this._isRejectionUnhandled()) { var reason = this._settledValue(); this._setUnhandledRejectionIsNotified(); fireRejectionEvent("unhandledRejection", possiblyUnhandledRejection, reason, this); } }
n/a
_notifyUnhandledRejectionIsHandled = function () { fireRejectionEvent("rejectionHandled", unhandledRejectionHandled, undefined, this); }
n/a
_onCancel = function () {}
n/a
_passThrough = function (handler, type, success, fail) { if (typeof handler !== "function") return this.then(); return this._then(success, fail, undefined, new PassThroughHandlerContext(this, type, handler), undefined); }
n/a
_peekContext = function () {}
n/a
_popContext = function () {return null;}
n/a
_promiseAt = function (index) { return this[ index * 4 - 4 + 2]; }
n/a
_promiseCreated = function () {}
n/a
_propagateFrom = function (parent, flags) { ; ; }
n/a
_proxy = function (proxyable, arg) { this._addCallbacks(undefined, undefined, arg, proxyable, null); }
n/a
_pushContext = function () {}
n/a
_reason = function () { this._unsetRejectionIsUnhandled(); return this._settledValue(); }
n/a
_receiverAt = function (index) { var ret = index === 0 ? this._receiver0 : this[ index * 4 - 4 + 3]; if (ret === UNDEFINED_BINDING) { return undefined; } else if (ret === undefined && this._isBound()) { return this._boundValue(); } return ret; }
n/a
_reject = function (reason) { var bitField = this._bitField; if (((bitField & 117506048) >>> 16)) return; this._setRejected(); this._fulfillmentHandler0 = reason; if (this._isFinal()) { return async.fatalError(reason, util.isNode); } if ((bitField & 65535) > 0) { async.settlePromises(this); } else { this._ensurePossibleRejectionHandled(); } }
n/a
_rejectCallback = function (reason, synchronous, ignoreNonErrorWarnings) { var trace = util.ensureErrorObject(reason); var hasStack = trace === reason; if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) { var message = "a promise was rejected with a non-error: " + util.classString(reason); this._warn(message, true); } this._attachExtraTrace(trace, synchronous ? hasStack : false); this._reject(reason); }
n/a
_rejectPromises = function (len, reason) { for (var i = 1; i < len; i++) { var handler = this._rejectionHandlerAt(i); var promise = this._promiseAt(i); var receiver = this._receiverAt(i); this._clearCallbackDataAtIndex(i); this._settlePromise(promise, handler, receiver, reason); } }
n/a
_rejectionHandlerAt = function (index) { return this[ index * 4 - 4 + 1]; }
n/a
_resolveCallback = function (value, shouldBind) { if (((this._bitField & 117506048) !== 0)) return; if (value === this) return this._rejectCallback(makeSelfResolutionError(), false); var maybePromise = tryConvertToPromise(value, this); if (!(maybePromise instanceof Promise)) return this._fulfill(value); if (shouldBind) this._propagateFrom(maybePromise, 2); var promise = maybePromise._target(); if (promise === this) { this._reject(makeSelfResolutionError()); return; } var bitField = promise._bitField; if (((bitField & 50397184) === 0)) { var len = this._length(); if (len > 0) promise._migrateCallback0(this); for (var i = 1; i < len; ++i) { promise._migrateCallbackAt(this, i); } this._setFollowing(); this._setLength(0); this._setFollowee(promise); } else if (((bitField & 33554432) !== 0)) { this._fulfill(promise._value()); } else if (((bitField & 16777216) !== 0)) { this._reject(promise._reason()); } else { var reason = new CancellationError("late cancellation observer"); promise._attachExtraTrace(reason); this._reject(reason); } }
n/a
_resolveFromExecutor = function (executor) { if (executor === INTERNAL) return; var promise = this; this._captureStackTrace(); this._pushContext(); var synchronous = true; var r = this._execute(executor, function(value) { promise._resolveCallback(value); }, function (reason) { promise._rejectCallback(reason, synchronous); }); synchronous = false; this._popContext(); if (r !== undefined) { promise._rejectCallback(r, true); } }
n/a
_resolveFromSyncValue = function (value) { if (value === util.errorObj) { this._rejectCallback(value.e, false); } else { this._resolveCallback(value, true); } }
n/a
_resultCancelled = function () { this.cancel(); }
n/a
_returnedNonUndefined = function () { return (this._bitField & 268435456) !== 0; }
n/a
_setAsyncGuaranteed = function () { if (async.hasCustomScheduler()) return; this._bitField = this._bitField | 134217728; }
n/a
_setBoundTo = function (obj) { if (obj !== undefined) { this._bitField = this._bitField | 2097152; this._boundTo = obj; } else { this._bitField = this._bitField & (~2097152); } }
n/a
_setCancelled = function () { this._bitField = this._bitField | 65536; this._fireEvent("promiseCancelled", this); }
n/a
_setDisposable = function (disposer) { this._bitField = this._bitField | 131072; this._disposer = disposer; }
n/a
_setFollowee = function (promise) { this._rejectionHandler0 = promise; }
n/a
_setFollowing = function () { this._bitField = this._bitField | 67108864; this._fireEvent("promiseResolved", this); }
n/a
_setFulfilled = function () { this._bitField = this._bitField | 33554432; this._fireEvent("promiseFulfilled", this); }
n/a
_setIsFinal = function () { this._bitField = this._bitField | 4194304; }
n/a
_setLength = function (len) { this._bitField = (this._bitField & -65536) | (len & 65535); }
n/a
_setOnCancel = function (handler) { ; }
n/a
_setRejected = function () { this._bitField = this._bitField | 16777216; this._fireEvent("promiseRejected", this); }
n/a
_setRejectionIsUnhandled = function () { this._bitField = this._bitField | 1048576; }
n/a
_setReturnedNonUndefined = function () { this._bitField = this._bitField | 268435456; }
n/a
_setUnhandledRejectionIsNotified = function () { this._bitField = this._bitField | 262144; }
n/a
_setWillBeCancelled = function () { this._bitField = this._bitField | 8388608; }
n/a
_settlePromise = function (promise, handler, receiver, value) { var isPromise = promise instanceof Promise; var bitField = this._bitField; var asyncGuaranteed = ((bitField & 134217728) !== 0); if (((bitField & 65536) !== 0)) { if (isPromise) promise._invokeInternalOnCancel(); if (receiver instanceof PassThroughHandlerContext && receiver.isFinallyHandler()) { receiver.cancelPromise = promise; if (tryCatch(handler).call(receiver, value) === errorObj) { promise._reject(errorObj.e); } } else if (handler === reflectHandler) { promise._fulfill(reflectHandler.call(receiver)); } else if (receiver instanceof Proxyable) { receiver._promiseCancelled(promise); } else if (isPromise || promise instanceof PromiseArray) { promise._cancel(); } else { receiver.cancel(); } } else if (typeof handler === "function") { if (!isPromise) { handler.call(receiver, value, promise); } else { if (asyncGuaranteed) promise._setAsyncGuaranteed(); this._settlePromiseFromHandler(handler, receiver, value, promise); } } else if (receiver instanceof Proxyable) { if (!receiver._isResolved()) { if (((bitField & 33554432) !== 0)) { receiver._promiseFulfilled(value, promise); } else { receiver._promiseRejected(value, promise); } } } else if (isPromise) { if (asyncGuaranteed) promise._setAsyncGuaranteed(); if (((bitField & 33554432) !== 0)) { promise._fulfill(value); } else { promise._reject(value); } } }
n/a
_settlePromise0 = function (handler, value, bitField) { var promise = this._promise0; var receiver = this._receiverAt(0); this._promise0 = undefined; this._receiver0 = undefined; this._settlePromise(promise, handler, receiver, value); }
n/a
_settlePromiseCtx = function (ctx) { this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value); }
n/a
_settlePromiseFromHandler = function ( handler, receiver, value, promise ) { var bitField = promise._bitField; if (((bitField & 65536) !== 0)) return; promise._pushContext(); var x; if (receiver === APPLY) { if (!value || typeof value.length !== "number") { x = errorObj; x.e = new TypeError("cannot .spread() a non-array: " + util.classString(value)); } else { x = tryCatch(handler).apply(this._boundValue(), value); } } else { x = tryCatch(handler).call(receiver, value); } var promiseCreated = promise._popContext(); bitField = promise._bitField; if (((bitField & 65536) !== 0)) return; if (x === NEXT_FILTER) { promise._reject(value); } else if (x === errorObj) { promise._rejectCallback(x.e, false); } else { debug.checkForgottenReturns(x, promiseCreated, "", promise, this); promise._resolveCallback(x); } }
n/a
_settlePromiseLateCancellationObserver = function (ctx) { var handler = ctx.handler; var promise = ctx.promise; var receiver = ctx.receiver; var value = ctx.value; if (typeof handler === "function") { if (!(promise instanceof Promise)) { handler.call(receiver, value, promise); } else { this._settlePromiseFromHandler(handler, receiver, value, promise); } } else if (promise instanceof Promise) { promise._reject(value); } }
n/a
_settlePromises = function () { var bitField = this._bitField; var len = (bitField & 65535); if (len > 0) { if (((bitField & 16842752) !== 0)) { var reason = this._fulfillmentHandler0; this._settlePromise0(this._rejectionHandler0, reason, bitField); this._rejectPromises(len, reason); } else { var value = this._rejectionHandler0; this._settlePromise0(this._fulfillmentHandler0, value, bitField); this._fulfillPromises(len, value); } this._setLength(0); } this._clearCancellationData(); }
n/a
_settledValue = function () { var bitField = this._bitField; if (((bitField & 33554432) !== 0)) { return this._rejectionHandler0; } else if (((bitField & 16777216) !== 0)) { return this._fulfillmentHandler0; } }
n/a
_target = function () { var ret = this; while (ret._isFollowing()) ret = ret._followee(); return ret; }
n/a
_then = function ( didFulfill, didReject, _, receiver, internalData ) { var haveInternalData = internalData !== undefined; var promise = haveInternalData ? internalData : new Promise(INTERNAL); var target = this._target(); var bitField = target._bitField; if (!haveInternalData) { promise._propagateFrom(this, 3); promise._captureStackTrace(); if (receiver === undefined && ((this._bitField & 2097152) !== 0)) { if (!((bitField & 50397184) === 0)) { receiver = this._boundValue(); } else { receiver = target === this ? undefined : this._boundTo; } } this._fireEvent("promiseChained", this, promise); } var domain = getDomain(); if (!((bitField & 50397184) === 0)) { var handler, value, settler = target._settlePromiseCtx; if (((bitField & 33554432) !== 0)) { value = target._rejectionHandler0; handler = didFulfill; } else if (((bitField & 16777216) !== 0)) { value = target._fulfillmentHandler0; handler = didReject; target._unsetRejectionIsUnhandled(); } else { settler = target._settlePromiseLateCancellationObserver; value = new CancellationError("late cancellation observer"); target._attachExtraTrace(value); handler = didReject; } async.invoke(settler, target, { handler: domain === null ? handler : (typeof handler === "function" && util.domainBind(domain, handler)), promise: promise, receiver: receiver, value: value }); } else { target._addCallbacks(didFulfill, didReject, promise, receiver, domain); } return promise; }
n/a
_unsetCancelled = function () { this._bitField = this._bitField & (~65536); }
n/a
_unsetDisposable = function () { this._bitField = this._bitField & (~131072); this._disposer = undefined; }
n/a
_unsetOnCancel = function () { this._onCancelField = undefined; }
n/a
_unsetRejectionIsUnhandled = function () { this._bitField = this._bitField & (~1048576); if (this._isUnhandledRejectionNotified()) { this._unsetUnhandledRejectionIsNotified(); this._notifyUnhandledRejectionIsHandled(); } }
n/a
_unsetUnhandledRejectionIsNotified = function () { this._bitField = this._bitField & (~262144); }
n/a
_value = function () { return this._settledValue(); }
n/a
_warn = function (message, shouldUseOwnTrace, promise) { return warn(message, shouldUseOwnTrace, promise || this); }
n/a
all = function () { if (arguments.length > 0) { this._warn(".all() was passed arguments but it does not take any"); } return new PromiseArray(this).promise(); }
...
* **cluster:** support scaling reads to slaves ([98bdec2](https://github.com/luin/ioredis/commit/98bdec2)), closes [#170](https://
github.com/luin/ioredis/issues/170)
* **redis:** support readonly mode for cluster ([0a4186e](https://github.com/luin/ioredis/commit/0a4186e))
### BREAKING CHANGES
* **cluster:** `Cluster#masterNodes` and `Cluster#nodes` is removed. Use `Cluster#nodes('masters')` and `Cluster#nodes
('all')` instead.
* **cluster:** `Cluster#to()` is removed. Use `Promise.all(Cluster#nodes().map(function
(node) {}))` instead.
* **cluster:** Option `readOnly` is removed. Check out `scaleReads` option.
<a name="1.15.1"></a>
## [1.15.1](https://github.com/luin/ioredis/compare/v1.15.0...v1.15.1) (2016-02-19)
* select db on connect event to prevent subscribe errors ([829bf26](https://github.com/luin/ioredis/commit/829bf26)), closes [#255
](https://github.com/luin/ioredis/issues/255)
<a name="1.15.0"></a>
...
any = function () { return any(this); }
n/a
asCallback = function (nodeback, options) { if (typeof nodeback == "function") { var adapter = successAdapter; if (options !== undefined && Object(options).spread) { adapter = spreadAdapter; } this._then( adapter, errorAdapter, undefined, this, nodeback ); } return this; }
n/a
bind = function (thisArg) { if (!calledBind) { calledBind = true; Promise.prototype._propagateFrom = debug.propagateFromFunction(); Promise.prototype._boundValue = debug.boundValueFunction(); } var maybePromise = tryConvertToPromise(thisArg); var ret = new Promise(INTERNAL); ret._propagateFrom(this, 1); var target = this._target(); ret._setBoundTo(maybePromise); if (maybePromise instanceof Promise) { var context = { promiseRejectionQueued: false, promise: ret, target: target, bindingPromise: maybePromise }; target._then(INTERNAL, targetRejected, undefined, ret, context); maybePromise._then( bindingResolved, bindingRejected, undefined, ret, context); ret._setOnCancel(maybePromise); } else { ret._resolveCallback(target); } return ret; }
...
address = this.stream.remoteAddress + ':' + this.stream.remotePort;
} else {
address = this.options.host + ':' + this.options.port;
}
debug('status[%s]: %s -> %s', address, this.status || '[empty]', status);
this.status = status;
process.nextTick(this.emit.bind(this, status, arg));
};
/**
* Create a connection to Redis.
* This method will be invoked automatically when creating a new Redis instance.
* @param {function} callback
* @return {Promise}
...
break = function () { if (!debug.cancellation()) return this._warn("cancellation is disabled"); var promise = this; var child = promise; while (promise._isCancellable()) { if (!promise._cancelBy(child)) { if (child._isFollowing()) { child._followee().cancel(); } else { child._cancelBranched(); } break; } var parent = promise._cancellationParent; if (parent == null || !parent._isCancellable()) { if (promise._isFollowing()) { promise._followee().cancel(); } else { promise._cancelBranched(); } break; } else { if (promise._isFollowing()) promise._followee().cancel(); promise._setWillBeCancelled(); child = promise; promise = parent; } } }
n/a
call = function (methodName) { var $_len = arguments.length;var args = new Array(Math.max($_len - 1, 0)); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];}; if (!false) { if (canEvaluate) { var maybeCaller = getMethodCaller(methodName); if (maybeCaller !== null) { return this._then( maybeCaller, undefined, undefined, args, undefined); } } } args.push(methodName); return this._then(caller, undefined, undefined, args, undefined); }
...
var fbuffer = require('flexbuffer');
var Promise = require('bluebird');
var util = require('util');
var commands = require('redis-commands');
var calculateSlot = require('cluster-key-slot');
function Pipeline(redis) {
Commander.call(this);
this.redis = redis;
this.isCluster = this.redis.constructor.name === 'Cluster';
this.options = redis.options;
this._queue = [];
this._result = [];
this._transactions = 0;
...
cancel = function () { if (!debug.cancellation()) return this._warn("cancellation is disabled"); var promise = this; var child = promise; while (promise._isCancellable()) { if (!promise._cancelBy(child)) { if (child._isFollowing()) { child._followee().cancel(); } else { child._cancelBranched(); } break; } var parent = promise._cancellationParent; if (parent == null || !parent._isCancellable()) { if (promise._isFollowing()) { promise._followee().cancel(); } else { promise._cancelBranched(); } break; } else { if (promise._isFollowing()) promise._followee().cancel(); promise._setWillBeCancelled(); child = promise; promise = parent; } } }
n/a
catch = function (fn) { var len = arguments.length; if (len > 1) { var catchInstances = new Array(len - 1), j = 0, i; for (i = 0; i < len - 1; ++i) { var item = arguments[i]; if (util.isObject(item)) { catchInstances[j++] = item; } else { return apiRejection("Catch statement predicate: " + "expecting an object but got " + util.classString(item)); } } catchInstances.length = j; fn = arguments[i]; return this.then(undefined, catchFilter(catchInstances, fn, this)); } return this.then(undefined, fn); }
...
Pipeline.prototype.sendCommand = function (command) {
var position = this._queue.length;
var _this = this;
command.promise.then(function (result) {
_this.fillResult([null, result], position);
}).catch(function (error) {
_this.fillResult([error], position);
});
this._queue.push(command);
return this;
};
...
catchReturn = function (value) { if (arguments.length <= 1) { if (value instanceof Promise) value.suppressUnhandledRejections(); return this._then( undefined, returner, undefined, {value: value}, undefined); } else { var _value = arguments[1]; if (_value instanceof Promise) _value.suppressUnhandledRejections(); var handler = function() {return _value;}; return this.caught(value, handler); } }
n/a
catchThrow = function (reason) { if (arguments.length <= 1) { return this._then( undefined, thrower, undefined, {reason: reason}, undefined); } else { var _reason = arguments[1]; var handler = function() {throw _reason;}; return this.caught(reason, handler); } }
n/a
caught = function (fn) { var len = arguments.length; if (len > 1) { var catchInstances = new Array(len - 1), j = 0, i; for (i = 0; i < len - 1; ++i) { var item = arguments[i]; if (util.isObject(item)) { catchInstances[j++] = item; } else { return apiRejection("Catch statement predicate: " + "expecting an object but got " + util.classString(item)); } } catchInstances.length = j; fn = arguments[i]; return this.then(undefined, catchFilter(catchInstances, fn, this)); } return this.then(undefined, fn); }
n/a
delay = function (ms) { return delay(ms, this); }
n/a
disposer = function (fn) { if (typeof fn === "function") { return new FunctionDisposer(fn, this, createContext()); } throw new TypeError(); }
n/a
done = function (didFulfill, didReject) { var promise = this._then(didFulfill, didReject, undefined, undefined, undefined); promise._setIsFinal(); }
n/a
each = function (fn) { return PromiseReduce(this, fn, INTERNAL, 0) ._then(promiseAllThis, undefined, undefined, this, undefined); }
n/a
error = function (fn) { return this.caught(util.originatesFromRejection, fn); }
...
}
}
}
if (this.listeners(eventName).length > 0) {
return this.emit.apply(this, arguments);
}
if (error && error instanceof Error) {
console.error('[ioredis] Unhandled error event:', error.stack);
}
return false;
};
/**
* Listen for all requests received by the server in real time.
*
...
filter = function (fn, options) { return PromiseMap(this, fn, options, INTERNAL); }
n/a
finally = function (handler) { return this._passThrough(handler, 0, finallyHandler, finallyHandler); }
n/a
get = function (propertyName) { var isIndex = (typeof propertyName === "number"); var getter; if (!isIndex) { if (canEvaluate) { var maybeGetter = getGetter(propertyName); getter = maybeGetter !== null ? maybeGetter : namedGetter; } else { getter = namedGetter; } } else { getter = indexedGetter; } return this._then(getter, undefined, undefined, propertyName, undefined); }
...
## Basic Usage
```javascript
var Redis = require('ioredis');
var redis = new Redis();
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
...
isCancellable = function () { return this.isPending() && !this.isCancelled(); }
n/a
isCancelled = function () { return (this._target()._bitField & 8454144) !== 0; }
n/a
isFulfilled = function () { return isFulfilled.call(this._target()); }
n/a
isPending = function () { return isPending.call(this._target()); }
n/a
isRejected = function () { return isRejected.call(this._target()); }
n/a
isResolved = function () { return isResolved.call(this._target()); }
n/a
lastly = function (handler) { return this._passThrough(handler, 0, finallyHandler, finallyHandler); }
n/a
map = function (fn, options) { return map(this, fn, options, null); }
...
* **cluster:** support scaling reads to slaves ([98bdec2](https://github.com/luin/ioredis/commit/98bdec2)), closes [#170](https://
github.com/luin/ioredis/issues/170)
* **redis:** support readonly mode for cluster ([0a4186e](https://github.com/luin/ioredis/commit/0a4186e))
### BREAKING CHANGES
* **cluster:** `Cluster#masterNodes` and `Cluster#nodes` is removed. Use `Cluster#nodes('masters')` and `Cluster#nodes
('all')` instead.
* **cluster:** `Cluster#to()` is removed. Use `Promise.all(Cluster#nodes().map(function
(node) {}))` instead.
* **cluster:** Option `readOnly` is removed. Check out `scaleReads` option.
<a name="1.15.1"></a>
## [1.15.1](https://github.com/luin/ioredis/compare/v1.15.0...v1.15.1) (2016-02-19)
* select db on connect event to prevent subscribe errors ([829bf26](https://github.com/luin/ioredis/commit/829bf26)), closes [#255
](https://github.com/luin/ioredis/issues/255)
<a name="1.15.0"></a>
...
mapSeries = function (fn) { return PromiseReduce(this, fn, INTERNAL, INTERNAL); }
n/a
nodeify = function (nodeback, options) { if (typeof nodeback == "function") { var adapter = successAdapter; if (options !== undefined && Object(options).spread) { adapter = spreadAdapter; } this._then( adapter, errorAdapter, undefined, this, nodeback ); } return this; }
...
for (var i = firstArgIndex; i < length; ++i) {
args[i - firstArgIndex] = arguments[i];
}
var options;
if (this.options.dropBufferSupport) {
if (!_encoding) {
return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback);
}
options = { replyEncoding: null };
} else {
options = { replyEncoding: _encoding };
}
if (this.options.showFriendlyErrorStack) {
...
props = function () { return props(this); }
n/a
race = function () { return race(this, undefined); }
n/a
reason = function () { var target = this._target(); target._unsetRejectionIsUnhandled(); return reason.call(target); }
n/a
reduce = function (fn, initialValue) { return reduce(this, fn, initialValue, null); }
...
ENTER_SUBSCRIBER_MODE: ['subscribe', 'psubscribe'],
// Commands that may make current connection quit subscriber mode
EXIT_SUBSCRIBER_MODE: ['unsubscribe', 'punsubscribe'],
// Commands that will make client disconnect from server TODO shutdown?
WILL_DISCONNECT: ['quit']
};
var flagMap = Object.keys(Command.FLAGS).reduce(function (map, flagName) {
map[flagName] = {};
Command.FLAGS[flagName].forEach(function (commandName) {
map[flagName][commandName] = true;
});
return map;
}, {});
...
reflect = function () { return this._then(reflectHandler, reflectHandler, undefined, this, undefined); }
n/a
return = function (value) { if (value instanceof Promise) value.suppressUnhandledRejections(); return this._then( returner, undefined, undefined, {value: value}, undefined); }
n/a
settle = function () { return Promise.settle(this); }
n/a
some = function (howMany) { return some(this, howMany); }
...
}
if (Array.isArray(result)) {
for (var i = 0; i < result.length; ++i) {
var sentinel = utils.packObject(result[i]);
var flags = sentinel.flags ? sentinel.flags.split(',') : [];
if (flags.indexOf('disconnected') === -1 && sentinel.ip && sentinel.port) {
var endpoint = { host: sentinel.ip, port: parseInt(sentinel.port, 10) };
var isDuplicate = _this.sentinels.some(_.bind(isSentinelEql, null, endpoint));
if (!isDuplicate) {
debug('adding sentinel %s:%s', endpoint.host, endpoint.port);
_this.sentinels.push(endpoint);
}
}
}
debug('sentinels', _this.sentinels);
...
spread = function (fn) { if (typeof fn !== "function") { return apiRejection("expecting a function but got " + util.classString(fn)); } return this.all()._then(fn, undefined, undefined, APPLY, undefined); }
n/a
suppressUnhandledRejections = function () { var target = this._target(); target._bitField = ((target._bitField & (~1048576)) | 524288); }
n/a
tap = function (handler) { return this._passThrough(handler, 1, finallyHandler); }
n/a
tapCatch = function (handlerOrPredicate) { var len = arguments.length; if(len === 1) { return this._passThrough(handlerOrPredicate, 1, undefined, finallyHandler); } else { var catchInstances = new Array(len - 1), j = 0, i; for (i = 0; i < len - 1; ++i) { var item = arguments[i]; if (util.isObject(item)) { catchInstances[j++] = item; } else { return Promise.reject(new TypeError( "tapCatch statement predicate: " + "expecting an object but got " + util.classString(item) )); } } catchInstances.length = j; var handler = arguments[i]; return this._passThrough(catchFilter(catchInstances, handler, this), 1, undefined, finallyHandler); } }
n/a
then = function (didFulfill, didReject) { if (debug.warnings() && arguments.length > 0 && typeof didFulfill !== "function" && typeof didReject !== "function") { var msg = ".then() only accepts functions but was passed: " + util.classString(didFulfill); if (arguments.length > 1) { msg += ", " + util.classString(didReject); } this._warn(msg); } return this._then(didFulfill, didReject, undefined, undefined, undefined); }
...
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
// Arguments to commands are flattened, so the following are the same:
redis.sadd('set', 1, 3, 5, 7);
redis.sadd('set', [1, 3, 5, 7]);
...
thenReturn = function (value) { if (value instanceof Promise) value.suppressUnhandledRejections(); return this._then( returner, undefined, undefined, {value: value}, undefined); }
n/a
thenThrow = function (reason) { return this._then( thrower, undefined, undefined, {reason: reason}, undefined); }
n/a
throw = function (reason) { return this._then( thrower, undefined, undefined, {reason: reason}, undefined); }
n/a
timeout = function (ms, message) { ms = +ms; var ret, parent; var handleWrapper = new HandleWrapper(setTimeout(function timeoutTimeout() { if (ret.isPending()) { afterTimeout(ret, message, parent); } }, ms)); if (debug.cancellation()) { parent = this.then(); ret = parent._then(successClear, failureClear, undefined, handleWrapper, undefined); ret._setOnCancel(handleWrapper); } else { ret = this._then(successClear, failureClear, undefined, handleWrapper, undefined); } return ret; }
...
};
Cluster.prototype.getInfoFromNode = function (redis, callback) {
if (!redis) {
return callback(new Error('Node is disconnected'));
}
var _this = this;
redis.cluster('slots', utils.timeout(function (err, result) {
if (err) {
redis.disconnect();
return callback(err);
}
var nodes = [];
for (var i = 0; i < result.length; ++i) {
...
toJSON = function () { var ret = { isFulfilled: false, isRejected: false, fulfillmentValue: undefined, rejectionReason: undefined }; if (this.isFulfilled()) { ret.fulfillmentValue = this.value(); ret.isFulfilled = true; } else if (this.isRejected()) { ret.rejectionReason = this.reason(); ret.isRejected = true; } return ret; }
n/a
toString = function () { return "[object Promise]"; }
...
}
var _this = this;
this.opt.redis[this.opt.command](args, function (err, res) {
if (err) {
_this.emit('error', err);
return;
}
_this._redisCursor = (res[0] instanceof Buffer) ? res[0].toString() : res[0];
if (_this._redisCursor === '0') {
_this._redisDrained = true;
}
_this.push(res[1]);
});
};
...
value = function () { return value.call(this._target()); }
n/a
function ReplyError(message) { Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.message = message; }
n/a
function Error() { [native code] }
n/a
function Error() { [native code] }
n/a
function captureStackTrace() { [native code] }
...
'use strict';
module.exports = function ReplyError(message) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
};
require('util').inherits(module.exports, Error);
...
function Commander() { this.options = _.defaults({}, this.options || {}, { showFriendlyErrorStack: false }); this.scriptsSet = {}; }
n/a
append = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
appendBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
asking = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
key = nodeKeys[0];
}
redis = _this.connectionPool.nodes.all[key];
}
}
if (asking) {
redis = _this.connectionPool.nodes.all[asking];
redis.asking();
}
}
if (!redis) {
redis = _.sample(_this.connectionPool.nodes[to]) ||
_.sample(_this.connectionPool.nodes.all);
}
}
...
askingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
auth = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
self.setStatus('connect');
self.resetCommandQueue();
// AUTH command should be processed before any other commands
var flushed = false;
if (self.condition.auth) {
self.auth(self.condition.auth, function (err) {
if (err) {
if (err.message.indexOf('no password is set') === -1) {
flushed = true;
self.flushQueue(err);
self.silentEmit('error', err);
self.disconnect(true);
} else {
...
authBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgrewriteaof = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgrewriteaofBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgsave = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgsaveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitfield = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitfieldBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitpos = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitposBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
blpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
blpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpoplpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpoplpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
call = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
var fbuffer = require('flexbuffer');
var Promise = require('bluebird');
var util = require('util');
var commands = require('redis-commands');
var calculateSlot = require('cluster-key-slot');
function Pipeline(redis) {
Commander.call(this);
this.redis = redis;
this.isCluster = this.redis.constructor.name === 'Cluster';
this.options = redis.options;
this._queue = [];
this._result = [];
this._transactions = 0;
...
callBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
client = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
return;
}
var item;
var finalSelect = self.prevCondition ? self.prevCondition.select : self.condition.select;
if (self.options.connectionName) {
debug('set the connection name [%s]', self.options.connectionName);
self.client('setname', self.options.connectionName);
}
if (self.options.readOnly) {
debug('set the connection to readonly mode');
self.readonly().catch(_.noop);
}
...
clientBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
cluster = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
};
Cluster.prototype.getInfoFromNode = function (redis, callback) {
if (!redis) {
return callback(new Error('Node is disconnected'));
}
var _this = this;
redis.cluster('slots', utils.timeout(function (err, result) {
if (err) {
redis.disconnect();
return callback(err);
}
var nodes = [];
for (var i = 0; i < result.length; ++i) {
...
clusterBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
command = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
commandBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
config = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
configBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
createBuiltinCommand = function (commandName) { return { string: generateFunction(commandName, 'utf8'), buffer: generateFunction(commandName, null) }; }
n/a
dbsize = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
dbsizeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
debug = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
debugBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
defineCommand = function (name, definition) { var script = new Script(definition.lua, definition.numberOfKeys, this.options.keyPrefix); this.scriptsSet[name] = script; this[name] = generateScriptingFunction(script, 'utf8'); this[name + 'Buffer'] = generateScriptingFunction(script, null); }
...
care of script caching and to detect when to use `EVAL` and when to use `EVALSHA`.
ioredis expose a `defineCommand` method to make scripting much easier to use:
```javascript
var redis = new Redis();
// This will define a command echo:
redis.defineCommand('echo', {
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (err, result) {
...
del = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
`redis.pipeline()` creates a `Pipeline` instance. You can call any Redis
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
pipeline.exec(function (err, results) {
// `err` is always null, and `results` is an array of responses
// corresponding to the sequence of queued commands.
// Each response follows the format `[err, result]`.
});
// You can even chain the commands:
...
delBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
discard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
discardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
dump = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
dumpBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
echo = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
redis.defineCommand('echo', {
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (
err, result) {
// result === ['k1', 'k2', 'a1', 'a2']
});
// `echoBuffer` is also defined automatically to return buffers instead of strings:
redis.echoBuffer('k1', 'k2', 'a1', 'a2', function (err, result) {
// result[0] === new Buffer('k1');
});
...
echoBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (err, result) {
// result === ['k1', 'k2', 'a1', 'a2']
});
// `echoBuffer` is also defined automatically to return buffers instead of strings:
redis.echoBuffer('k1', 'k2', 'a1', 'a2', function
(err, result) {
// result[0] === new Buffer('k1');
});
// And of course it works with pipeline:
redis.pipeline().set('foo', 'bar').echo('k1', 'k2', 'a1', 'a2').exec
();
```
...
eval = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalsha = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalshaBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
exec = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
pipeline.exec(function (err, results) {
// `err` is always null, and `results` is an array of responses
// corresponding to the sequence of queued commands.
// Each response follows the format `[err, result]`.
});
// You can even chain the commands:
redis.pipeline().set('foo', 'bar').del('cc').exec(function (err, results) {
...
execBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
exists = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
if (typeof this._keys === 'undefined') {
if (typeof transform !== 'function') {
transform = function (key) {
return key;
};
}
this._keys = [];
if (commands.exists(this.name)) {
var keyIndexes = commands.getKeyIndexes(this.name, this.args);
for (var i = 0; i < keyIndexes.length; i++) {
var index = keyIndexes[i];
this.args[index] = transform(this.args[index]);
this._keys.push(this.args[index]);
}
}
...
existsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expire = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushall = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushallBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushdb = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
`Cluster#nodes()` accepts a parameter role, which can be "master", "slave" and "all" (default), and
returns an array of `Redis` instance. For example:
```javascript
// Send `FLUSHDB` command to all slaves:
var slaves = cluster.nodes('slave');
Promise.all(slaves.map(function (node) {
return node.flushdb();
}));
// Get keys of all the masters:
var masters = cluster.nodes('master');
Promise.all(masters.map(function (node) {
return node.keys();
})).then(function (keys) {
...
flushdbBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geodist = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geodistBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geohash = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geohashBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geopos = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoposBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadius = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusbymember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusbymemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
get = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
## Basic Usage
```javascript
var Redis = require('ioredis');
var redis = new Redis();
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
...
getBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
redis.set('foo', new Buffer('bar'));
```
And every command has a method that returns a Buffer (by adding a suffix of "Buffer" to the command name).
To get a buffer instead of a utf8 string:
```javascript
redis.getBuffer('foo', function (err, result) {
// result is a buffer.
});
```
## Pipelining
If you want to send a batch of commands (e.g. > 5), you can use pipelining to queue
the commands in memory and then send them to Redis all at once. This way the performance improves by 50%~300% (See [benchmark section
](#benchmark)).
...
getBuiltinCommands = function () { return _.clone(commands); }
n/a
getbit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getbitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hdel = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hdelBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hexists = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hexistsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetall = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetallBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyfloat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyfloatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hkeys = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hkeysBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hstrlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hstrlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hvals = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hvalsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyfloat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyfloatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
info = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
* process commands.
*
* @param {Function} callback
* @private
*/
Redis.prototype._readyCheck = function (callback) {
var _this = this;
this.info(function (err, res) {
if (err) {
return callback(err);
}
if (typeof res !== 'string') {
return callback(null, res);
}
...
infoBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
keys = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
Promise.all(slaves.map(function (node) {
return node.flushdb();
}));
// Get keys of all the masters:
var masters = cluster.nodes('master');
Promise.all(masters.map(function (node) {
return node.keys();
})).then(function (keys) {
// keys: [['key1', 'key2'], ['key3', 'key4']]
});
```
### Transaction and pipeline in Cluster mode
Almost all features that are supported by `Redis` are also supported by `Redis.Cluster`, e.g. custom commands, transaction and pipeline
.
...
keysBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lastsave = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lastsaveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
latency = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
latencyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lindex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lindexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
linsert = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
linsertBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
llen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
llenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ltrim = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ltrimBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
memory = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
memoryBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
migrate = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
migrateBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
module = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
moduleBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
move = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
moveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
```
There are three built-in transformers, two argument transformers for `hmset` & `mset` and
a reply transformer for `hgetall`. Transformers for `hmset` and `hgetall` were mentioned
above, and the transformer for `mset` is similar to the one for `hmset`:
```javascript
redis.mset({ k1: 'v1', k2: 'v2' });
redis.get('k1', function (err, result) {
// result === 'v1';
});
redis.mset(new Map([['k3', 'v3'], ['k4', 'v4']]));
redis.get('k3', function (err, result) {
// result === 'v3';
...
msetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
msetnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
msetnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
multi = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
## Transaction
Most of the time, the transaction commands `multi` & `exec` are used together with pipeline.
Therefore, when `multi` is called, a `Pipeline` instance is created automatically by default,
so you can use `multi` just like `pipeline`:
```javascript
redis.multi().set('foo', 'bar').get('foo').exec(function
(err, results) {
// results === [[null, 'OK'], [null, 'bar']]
});
```
If there's a syntax error in the transaction's command chain (e.g. wrong number of arguments, wrong command name, etc),
then none of the commands would be executed, and an error is returned:
```javascript
...
multiBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
object = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
objectBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
persist = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
persistBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpire = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfdebug = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfdebugBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfmerge = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfmergeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfselftest = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfselftestBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ping = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
post = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
postBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psetex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psetexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Both `channel` and `message` are buffers.
});
```
`PSUBSCRIBE` is also supported in a similar way:
```javascript
redis.psubscribe('pat?ern', function (err, count) {});
redis.on('pmessage', function (pattern, channel, message) {});
redis.on('pmessageBuffer', function (pattern, channel, message) {});
```
When a client issues a SUBSCRIBE or PSUBSCRIBE, that connection is put into a "subscriber" mode.
At that point, only commands that modify the subscription set are valid.
When the subscription set is empty, the connection is put back into regular mode.
...
psubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psync = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psyncBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pttl = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pttlBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
publish = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
var Redis = require('ioredis');
var redis = new Redis();
var pub = new Redis();
redis.subscribe('news', 'music', function (err, count) {
// Now we are subscribed to both the 'news' and 'music' channels.
// `count` represents the number of channels we are currently subscribed to.
pub.publish('news', 'Hello world!');
pub.publish('music', 'Hello again!');
});
redis.on('message', function (channel, message) {
// Receive message Hello world! from channel news
// Receive message Hello again! from channel music
console.log('Receive message %s from channel %s', message, channel);
...
publishBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pubsub = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pubsubBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
punsubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
punsubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
quit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
});
```
You can learn more from the [Redis documentation](http://redis.io/commands/scan).
## Auto-reconnect
By default, ioredis will try to reconnect when the connection to Redis is lost
except when the connection is closed manually by `redis.disconnect()` or `redis.quit()`.
It's very flexible to control how long to wait to reconnect after disconnection
using the `retryStrategy` option:
```javascript
var redis = new Redis({
// This is the default value of `retryStrategy`
...
quitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
randomkey = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
randomkeyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readonly = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
if (self.options.connectionName) {
debug('set the connection name [%s]', self.options.connectionName);
self.client('setname', self.options.connectionName);
}
if (self.options.readOnly) {
debug('set the connection to readonly mode');
self.readonly().catch(_.noop);
}
if (self.prevCondition) {
var condition = self.prevCondition;
self.prevCondition = null;
if (condition.subscriber && self.options.autoResubscribe) {
// We re-select the previous db first since
...
readonlyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readwrite = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readwriteBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rename = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renameBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renamenx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renamenxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
replconf = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
replconfBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restore-asking = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restore-askingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
role = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
roleBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpoplpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpoplpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
// Arguments to commands are flattened, so the following are the same:
redis.sadd('set', 1, 3, 5, 7);
redis.sadd('set', [1, 3, 5, 7]);
// All arguments are passed directly to the redis server:
redis.set('key', 100, 'EX', 10);
```
See the `examples/` folder for more examples.
...
saddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
save = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
saveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
script = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
}
var _this = this;
if (!scripts.length) {
return execPipeline();
}
return this.redis.script('exists', scripts.map(function (item) {
return item.sha;
})).then(function (results) {
var pending = [];
for (var i = 0; i < results.length; ++i) {
if (!results[i]) {
pending.push(scripts[i]);
}
...
scriptBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiff = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
select = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
console.warn('[WARN] Redis server does not require a password, but a password was supplied.');
}
}
});
}
if (self.condition.select) {
self.select(self.condition.select);
}
if (!self.options.enableReadyCheck) {
exports.readyHandler(self)();
}
self.initParser();
...
selectBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sendCommand = function () {}
...
if (this.options.showFriendlyErrorStack) {
options.errorStack = new Error().stack;
}
if (this.options.keyPrefix) {
options.keyPrefix = this.options.keyPrefix;
}
return this.sendCommand(new Command(commandName, args, options, callback));
};
}
function generateScriptingFunction(_script, _encoding) {
return function () {
var length = arguments.length;
var lastArgIndex = length - 1;
...
send_command = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sentinel = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
}
});
}
};
SentinelConnector.prototype.updateSentinels = function (client, callback) {
var _this = this;
client.sentinel('sentinels', this.options.name, function (err, result) {
if (err) {
client.disconnect();
return callback(err);
}
if (Array.isArray(result)) {
for (var i = 0; i < result.length; ++i) {
var sentinel = utils.packObject(result[i]);
...
sentinelBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
set = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
## Basic Usage
```javascript
var Redis = require('ioredis');
var redis = new Redis();
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
...
setBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setbit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setbitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
shutdown = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
shutdownBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinter = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sismember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sismemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slaveof = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slaveofBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slowlog = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slowlogBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smembers = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smembersBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smove = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smoveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sort = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Works well with pipelining/transaction
fooRedis.pipeline()
// Sends SORT foo:list BY foo:weight_*->fieldname
.sort('list', 'BY', 'weight_*->fieldname')
// Supports custom commands
// Sends EVALSHA xxx foo:k1 foo:k2 a1 a2
.echo('k1', 'k2', 'a1', 'a2')
.exec()
```
## Transforming Arguments & Replies
...
sortBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
spop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
spopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srandmember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srandmemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
strlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
strlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
subscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
It subscribes to a channel with one connection
and publishes to that channel with the other:
```javascript
var Redis = require('ioredis');
var redis = new Redis();
var pub = new Redis();
redis.subscribe('news', 'music', function (err, count) {
// Now we are subscribed to both the 'news' and 'music' channels.
// `count` represents the number of channels we are currently subscribed to.
pub.publish('news', 'Hello world!');
pub.publish('music', 'Hello again!');
});
...
subscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
substr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
substrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunion = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
swapdb = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
swapdbBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sync = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
syncBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
time = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
timeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
touch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
touchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ttl = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ttlBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
type = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
typeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unlink = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unlinkBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unsubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unsubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unwatch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unwatchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
wait = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
waitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
watch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
watchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zincrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zincrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zinterstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zinterstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zlexcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zlexcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zunionstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zunionstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
function ConnectionPool(redisOptions) { EventEmitter.call(this); this.redisOptions = redisOptions; // master + slave = all this.nodes = { all: {}, master: {}, slave: {} }; this.specifiedOptions = {}; }
n/a
function EventEmitter() { EventEmitter.init.call(this); }
n/a
findOrCreate = function (node, readOnly) { setKey(node); readOnly = Boolean(readOnly); if (this.specifiedOptions[node.key]) { _.assign(node, this.specifiedOptions[node.key]); } else { this.specifiedOptions[node.key] = node; } var redis; if (this.nodes.all[node.key]) { redis = this.nodes.all[node.key]; if (redis.options.readOnly !== readOnly) { redis.options.readOnly = readOnly; redis[readOnly ? 'readonly' : 'readwrite']().catch(_.noop); if (readOnly) { delete this.nodes.master[node.key]; this.nodes.slave[node.key] = redis; } else { delete this.nodes.slave[node.key]; this.nodes.master[node.key] = redis; } } } else { redis = new Redis(_.defaults({ retryStrategy: null, readOnly: readOnly }, node, this.redisOptions, { lazyConnect: true })); this.nodes.all[node.key] = redis; this.nodes[readOnly ? 'slave' : 'master'][node.key] = redis; var _this = this; redis.once('end', function () { delete _this.nodes.all[node.key]; delete _this.nodes.master[node.key]; delete _this.nodes.slave[node.key]; _this.emit('-node', redis); if (!Object.keys(_this.nodes.all).length) { _this.emit('drain'); } }); this.emit('+node', redis); redis.on('error', function (error) { _this.emit('nodeError', error); }); } return redis; }
...
var _this = this;
Object.keys(this.nodes.all).forEach(function (key) {
if (!newNodes[key]) {
_this.nodes.all[key].disconnect();
}
});
Object.keys(newNodes).forEach(function (key) {
_this.findOrCreate(newNodes[key], newNodes[key].readOnly);
});
};
/**
* Set key property
*
* @private
...
reset = function (nodes) { var newNodes = {}; nodes.forEach(function (node) { var options = {}; if (typeof node === 'object') { _.defaults(options, node); } else if (typeof node === 'string') { _.defaults(options, utils.parseURL(node)); } else if (typeof node === 'number') { options.port = node; } else { throw new Error('Invalid argument ' + node); } if (typeof options.port === 'string') { options.port = parseInt(options.port, 10); } delete options.db; setKey(options); newNodes[options.key] = options; }, this); var _this = this; Object.keys(this.nodes.all).forEach(function (key) { if (!newNodes[key]) { _this.nodes.all[key].disconnect(); } }); Object.keys(newNodes).forEach(function (key) { _this.findOrCreate(newNodes[key], newNodes[key].readOnly); }); }
...
}
this.setStatus('connecting');
if (!Array.isArray(this.startupNodes) || this.startupNodes.length === 0) {
throw new Error('`startupNodes` should contain at least one node.');
}
this.connectionPool.reset(this.startupNodes);
var closeListener;
var refreshListener = function () {
this.removeListener('close', closeListener);
this.manuallyClosing = false;
this.setStatus('connect');
if (this.options.enableReadyCheck) {
...
function Connector(options) { this.options = options; }
n/a
check = function () { return true; }
...
if (!flushed) {
self.flushQueue(new Error('Ready check failed: ' + err.message));
self.silentEmit('error', err);
self.disconnect(true);
}
} else {
self.serverInfo = info;
if (self.connector.check(info)) {
exports.readyHandler(self)();
} else {
self.disconnect(true);
}
}
});
}
...
connect = function (callback) { this.connecting = true; var connectionOptions; if (this.options.path) { connectionOptions = _.pick(this.options, ['path']); } else { connectionOptions = _.pick(this.options, ['port', 'host', 'family']); } if (this.options.tls) { _.assign(connectionOptions, this.options.tls); } var _this = this; process.nextTick(function () { if (!_this.connecting) { callback(new Error(utils.CONNECTION_CLOSED_ERROR_MSG)); return; } var stream; try { if (_this.options.tls) { stream = tls.connect(connectionOptions); } else { stream = net.createConnection(connectionOptions); } } catch (err) { callback(err); return; } _this.stream = stream; callback(null, stream); }); }
...
});
```
`retryStrategy` is a function that will be called when the connection is lost.
The argument `times` means this is the nth reconnection being made and
the return value represents how long (in ms) to wait to reconnect. When the
return value isn't a number, ioredis will stop trying to reconnect, and the connection
will be lost forever if the user doesn't call `redis.connect()` manually.
When reconnected, the client will auto subscribe to channels that the previous connection subscribed to.
This behavior can be disabled by setting the `autoResubscribe` option to `false`.
And if the previous connection has some unfulfilled commands (most likely blocking commands such as `brpop` and `blpop`),
the client will resend them when reconnected. This behavior can be disabled by setting the `autoResendUnfulfilledCommands` option
to `false`.
...
disconnect = function () { this.connecting = false; if (this.stream) { this.stream.end(); } }
...
});
```
You can learn more from the [Redis documentation](http://redis.io/commands/scan).
## Auto-reconnect
By default, ioredis will try to reconnect when the connection to Redis is lost
except when the connection is closed manually by `redis.disconnect()` or `redis.quit()`.
It's very flexible to control how long to wait to reconnect after disconnection
using the `retryStrategy` option:
```javascript
var redis = new Redis({
// This is the default value of `retryStrategy`
...
retryStrategy = function (times) { return Math.min(times * 2, 2000); }
...
return close();
}
if (typeof self.options.retryStrategy !== 'function') {
debug('skip reconnecting because `retryStrategy` is not a function');
return close();
}
var retryDelay = self.options.retryStrategy(++self.retryAttempts);
if (typeof retryDelay !== 'number') {
debug('skip reconnecting because `retryStrategy` doesn\'t return a number');
return close();
}
debug('reconnect in %sms', retryDelay);
...
sentinelRetryStrategy = function (times) { return Math.min(times * 10, 1000); }
...
function connectToNext() {
_this.currentPoint += 1;
if (_this.currentPoint === _this.sentinels.length) {
_this.currentPoint = -1;
var retryDelay;
if (typeof _this.options.sentinelRetryStrategy === 'function') {
retryDelay = _this.options.sentinelRetryStrategy(++_this.retryAttempts);
}
if (typeof retryDelay !== 'number') {
debug('All sentinels are unreachable and retry is disabled, emitting error...');
var error = 'All sentinels are unreachable.';
if (lastError) {
error += ' Last error: ' + lastError.message;
}
...
function DelayQueue() { this.queues = {}; this.timeouts = {}; }
n/a
_execute = function (bucket) { var queue = this.queues[bucket]; if (!queue) { return; } var length = queue.length; if (!length) { return; } debug('send %d commands in %s queue', length, bucket); this.queues[bucket] = null; while (queue.length > 0) { queue.shift()(); } }
...
queue.push(item);
if (!this.timeouts[bucket]) {
var _this = this;
this.timeouts[bucket] = setTimeout(function () {
callback(function () {
_this.timeouts[bucket] = null;
_this._execute(bucket);
});
}, options.timeout);
}
};
DelayQueue.prototype._execute = function (bucket) {
var queue = this.queues[bucket];
...
push = function (bucket, item, options) { var callback = options.callback || process.nextTick; if (!this.queues[bucket]) { this.queues[bucket] = new Deque(); } var queue = this.queues[bucket]; queue.push(item); if (!this.timeouts[bucket]) { var _this = this; this.timeouts[bucket] = setTimeout(function () { callback(function () { _this.timeouts[bucket] = null; _this._execute(bucket); }); }, options.timeout); } }
...
var redis = new Redis();
// Create a readable stream (object mode)
var stream = redis.scanStream();
var keys = [];
stream.on('data', function (resultKeys) {
// `resultKeys` is an array of strings representing key names
for (var i = 0; i < resultKeys.length; i++) {
keys.push(resultKeys[i]);
}
});
stream.on('end', function () {
console.log('done with the keys: ', keys);
});
```
...
closeHandler = function (self) { return function () { self.setStatus('close'); if (!self.prevCondition) { self.prevCondition = self.condition; } if (self.commandQueue.length) { self.prevCommandQueue = self.commandQueue; } if (self.manuallyClosing) { self.manuallyClosing = false; debug('skip reconnecting since the connection is manually closed.'); return close(); } if (typeof self.options.retryStrategy !== 'function') { debug('skip reconnecting because `retryStrategy` is not a function'); return close(); } var retryDelay = self.options.retryStrategy(++self.retryAttempts); if (typeof retryDelay !== 'number') { debug('skip reconnecting because `retryStrategy` doesn\'t return a number'); return close(); } debug('reconnect in %sms', retryDelay); self.setStatus('reconnecting', retryDelay); self.reconnectTimeout = setTimeout(function () { self.reconnectTimeout = null; self.connect().catch(_.noop); }, retryDelay); }; function close() { self.setStatus('end'); self.flushQueue(new Error(utils.CONNECTION_CLOSED_ERROR_MSG)); } }
...
_this.stream = stream;
if (typeof _this.options.keepAlive === 'number') {
stream.setKeepAlive(true, _this.options.keepAlive);
}
stream.once(CONNECT_EVENT, eventHandler.connectHandler(_this));
stream.once('error', eventHandler.errorHandler(_this));
stream.once('close', eventHandler.closeHandler(_this));
stream.on('data', eventHandler.dataHandler(_this));
if (_this.options.connectTimeout) {
stream.setTimeout(_this.options.connectTimeout, function () {
stream.setTimeout(0);
stream.destroy();
...
connectHandler = function (self) { return function () { self.setStatus('connect'); self.resetCommandQueue(); // AUTH command should be processed before any other commands var flushed = false; if (self.condition.auth) { self.auth(self.condition.auth, function (err) { if (err) { if (err.message.indexOf('no password is set') === -1) { flushed = true; self.flushQueue(err); self.silentEmit('error', err); self.disconnect(true); } else { console.warn('[WARN] Redis server does not require a password, but a password was supplied.'); } } }); } if (self.condition.select) { self.select(self.condition.select); } if (!self.options.enableReadyCheck) { exports.readyHandler(self)(); } self.initParser(); if (self.options.enableReadyCheck) { self._readyCheck(function (err, info) { if (err) { if (!flushed) { self.flushQueue(new Error('Ready check failed: ' + err.message)); self.silentEmit('error', err); self.disconnect(true); } } else { self.serverInfo = info; if (self.connector.check(info)) { exports.readyHandler(self)(); } else { self.disconnect(true); } } }); } }; }
...
var CONNECT_EVENT = _this.options.tls ? 'secureConnect' : 'connect';
_this.stream = stream;
if (typeof _this.options.keepAlive === 'number') {
stream.setKeepAlive(true, _this.options.keepAlive);
}
stream.once(CONNECT_EVENT, eventHandler.connectHandler(_this));
stream.once('error', eventHandler.errorHandler(_this));
stream.once('close', eventHandler.closeHandler(_this));
stream.on('data', eventHandler.dataHandler(_this));
if (_this.options.connectTimeout) {
stream.setTimeout(_this.options.connectTimeout, function () {
stream.setTimeout(0);
...
dataHandler = function (self) { return function (data) { self.replyParser.execute(data); }; }
...
if (typeof _this.options.keepAlive === 'number') {
stream.setKeepAlive(true, _this.options.keepAlive);
}
stream.once(CONNECT_EVENT, eventHandler.connectHandler(_this));
stream.once('error', eventHandler.errorHandler(_this));
stream.once('close', eventHandler.closeHandler(_this));
stream.on('data', eventHandler.dataHandler(_this));
if (_this.options.connectTimeout) {
stream.setTimeout(_this.options.connectTimeout, function () {
stream.setTimeout(0);
stream.destroy();
var err = new Error('connect ETIMEDOUT');
...
errorHandler = function (self) { return function (error) { debug('error: %s', error); self.silentEmit('error', error); }; }
...
_this.stream = stream;
if (typeof _this.options.keepAlive === 'number') {
stream.setKeepAlive(true, _this.options.keepAlive);
}
stream.once(CONNECT_EVENT, eventHandler.connectHandler(_this));
stream.once('error', eventHandler.errorHandler(_this));
stream.once('close', eventHandler.closeHandler(_this));
stream.on('data', eventHandler.dataHandler(_this));
if (_this.options.connectTimeout) {
stream.setTimeout(_this.options.connectTimeout, function () {
stream.setTimeout(0);
stream.destroy();
...
readyHandler = function (self) { return function () { self.setStatus('ready'); self.retryAttempts = 0; if (self.options.monitor) { self.call('monitor'); var sendCommand = self.sendCommand; self.sendCommand = function (command) { if (Command.checkFlag('VALID_IN_MONITOR_MODE', command.name)) { return sendCommand.call(self, command); } command.reject(new Error('Connection is in monitoring mode, can\'t process commands.')); return command.promise; }; self.once('close', function () { delete self.sendCommand; }); self.setStatus('monitoring'); return; } var item; var finalSelect = self.prevCondition ? self.prevCondition.select : self.condition.select; if (self.options.connectionName) { debug('set the connection name [%s]', self.options.connectionName); self.client('setname', self.options.connectionName); } if (self.options.readOnly) { debug('set the connection to readonly mode'); self.readonly().catch(_.noop); } if (self.prevCondition) { var condition = self.prevCondition; self.prevCondition = null; if (condition.subscriber && self.options.autoResubscribe) { // We re-select the previous db first since // `SELECT` command is not valid in sub mode. if (self.condition.select !== finalSelect) { debug('connect to db [%d]', finalSelect); self.select(finalSelect); } var subscribeChannels = condition.subscriber.channels('subscribe'); if (subscribeChannels.length) { debug('subscribe %d channels', subscribeChannels.length); self.subscribe(subscribeChannels); } var psubscribeChannels = condition.subscriber.channels('psubscribe'); if (psubscribeChannels.length) { debug('psubscribe %d channels', psubscribeChannels.length); self.psubscribe(psubscribeChannels); } } } if (self.prevCommandQueue) { if (self.options.autoResendUnfulfilledCommands) { debug('resend %d unfulfilled commands', self.prevCommandQueue.length); while (self.prevCommandQueue.length > 0) { item = self.prevCommandQueue.shift(); if (item.select !== self.condition.select && item.command.name !== 'select') { self.select(item.select); } self.sendCommand(item.command, item.stream); } } else { self.prevCommandQueue = null; } } if (self.offlineQueue.length) { debug('send %d commands in offline queue', self.offlineQueue.length); var offlineQueue = self.offlineQueue; self.resetOfflineQueue(); while (offlineQueue.length > 0) { item = offlineQueue.shift(); if (item.select !== self.condition.select && item.command.name !== 'select') { self.select(item.select); } self.sendCommand(item.command, item.stream); } } if (self.condition.select !== finalSelect) { debug('connect to db [%d]', finalSelect); self.select(finalSelect); } }; }
...
}
if (self.condition.select) {
self.select(self.condition.select);
}
if (!self.options.enableReadyCheck) {
exports.readyHandler(self)();
}
self.initParser();
if (self.options.enableReadyCheck) {
self._readyCheck(function (err, info) {
if (err) {
...
initParser = function () { var _this = this; this.replyParser = new Parser({ name: this.options.parser, stringNumbers: this.options.stringNumbers, returnBuffers: !this.options.dropBufferSupport, returnError: function (err) { _this.returnError(new ReplyError(err.message)); }, returnReply: function (reply) { _this.returnReply(reply); }, returnFatalError: function (err) { _this.flushQueue(err, { offlineQueue: false }); _this.silentEmit('error', new Error('Redis parser fatal error: ' + err.stack)); _this.disconnect(true); } }); if (this.replyParser.name === 'hiredis' && !this.options.dropBufferSupport) { console.warn('[WARN] ioredis is using hiredis parser, however "dropBufferSupport" is disabled. ' + 'It\'s highly recommended to enable this option. ' + 'Refer to https://github.com/luin/ioredis/wiki/Improve-Performance for more details.'); } }
...
self.select(self.condition.select);
}
if (!self.options.enableReadyCheck) {
exports.readyHandler(self)();
}
self.initParser();
if (self.options.enableReadyCheck) {
self._readyCheck(function (err, info) {
if (err) {
if (!flushed) {
self.flushQueue(new Error('Ready check failed: ' + err.message));
self.silentEmit('error', err);
...
returnError = function (err) { var item = this.commandQueue.shift(); err.command = { name: item.command.name, args: item.command.args }; var needReconnect = false; if (this.options.reconnectOnError) { needReconnect = this.options.reconnectOnError(err); } switch (needReconnect) { case 1: case true: if (this.status !== 'reconnecting') { this.disconnect(true); } item.command.reject(err); break; case 2: if (this.status !== 'reconnecting') { this.disconnect(true); } if (this.condition.select !== item.select && item.command.name !== 'select') { this.select(item.select); } this.sendCommand(item.command); break; default: item.command.reject(err); } }
...
var _this = this;
this.replyParser = new Parser({
name: this.options.parser,
stringNumbers: this.options.stringNumbers,
returnBuffers: !this.options.dropBufferSupport,
returnError: function (err) {
_this.returnError(new ReplyError(err.message));
},
returnReply: function (reply) {
_this.returnReply(reply);
},
returnFatalError: function (err) {
_this.flushQueue(err, { offlineQueue: false });
_this.silentEmit('error', new Error('Redis parser fatal error: ' + err.stack));
...
returnReply = function (reply) { if (this.status === 'monitoring') { // Valid commands in the monitoring mode are AUTH and MONITOR, // both of which always reply with 'OK'. var replyStr = reply.toString(); // If not the reply to AUTH & MONITOR if (replyStr !== 'OK') { // Since commands sent in the monitoring mode will trigger an exception, // any replies we received in the monitoring mode should consider to be // realtime monitor data instead of result of commands. var len = replyStr.indexOf(' '); var timestamp = replyStr.slice(0, len); var argindex = replyStr.indexOf('"'); var args = replyStr.slice(argindex + 1, -1).split('" "').map(function (elem) { return elem.replace(/\\"/g, '"'); }); var dbAndSource = replyStr.slice(len + 2, argindex - 2).split(' '); this.emit('monitor', timestamp, args, dbAndSource[1], dbAndSource[0]); return; } } var item, channel, count; if (this.condition.subscriber) { var replyType = Array.isArray(reply) ? reply[0].toString() : null; debug('receive reply "%s" in subscriber mode', replyType); switch (replyType) { case 'message': if (this.listeners('message').length > 0) { this.emit('message', reply[1].toString(), reply[2].toString()); } if (this.listeners('messageBuffer').length > 0) { this.emit('messageBuffer', reply[1], reply[2]); } break; case 'pmessage': var pattern = reply[1].toString(); if (this.listeners('pmessage').length > 0) { this.emit('pmessage', pattern, reply[2].toString(), reply[3].toString()); } if (this.listeners('pmessageBuffer').length > 0) { this.emit('pmessageBuffer', pattern, reply[2], reply[3]); } break; case 'subscribe': case 'psubscribe': channel = reply[1].toString(); this.condition.subscriber.add(replyType, channel); item = this.commandQueue.shift(); if (!fillSubCommand(item.command, reply[2])) { this.commandQueue.unshift(item); } break; case 'unsubscribe': case 'punsubscribe': channel = reply[1] ? reply[1].toString() : null; if (channel) { this.condition.subscriber.del(replyType, channel); } count = reply[2]; if (count === 0) { this.condition.subscriber = false; } item = this.commandQueue.shift(); if (!fillUnsubCommand(item.command, count)) { this.commandQueue.unshift(item); } break; default: item = this.commandQueue.shift(); item.command.resolve(reply); } } else { item = this.commandQueue.shift(); if (!item) { return this.emit('error', new Error('Command queue state error. If you can reproduce this, please report it. Last reply: ' + reply.toString())); } if (Command.checkFlag('ENTER_SUBSCRIBER_MODE', item.command.name)) { this.condition.subscriber = new SubscriptionSet(); this.condition.subscriber.add(item.command.name, reply[1].toString()); if (!fillSubCommand(item.command, reply[2])) { this.commandQueue.unshift(item); } } else if (Command.checkFlag('EXIT_SUBSCRIBER_MODE', item.command.name)) { if (!fillUnsubCommand(item.command, reply[2])) { this.commandQueue.unshift(item); } } else { item.command.resolve(reply); } } function fillSubCommand(command, count) { if (typeof command.remainReplies === 'undefined') { command.remainReplies = command.args.length; } if (--command.remainReplies === 0) { command.resolve(count); return true; } return false; } function fillUnsubCommand(command, count) { if (typeof command.remainReplies === 'undefined') { command.remainReplies = command.args.length; } if (command.remainReplies === 0) { if (count === 0) { command.resolve(reply[2]); return true; } return false; } if (--command.remainReplies === 0) { command.resolve(reply[2]); return t ...
...
name: this.options.parser,
stringNumbers: this.options.stringNumbers,
returnBuffers: !this.options.dropBufferSupport,
returnError: function (err) {
_this.returnError(new ReplyError(err.message));
},
returnReply: function (reply) {
_this.returnReply(reply);
},
returnFatalError: function (err) {
_this.flushQueue(err, { offlineQueue: false });
_this.silentEmit('error', new Error('Redis parser fatal error: ' + err.stack));
_this.disconnect(true);
}
});
...
function Pipeline(redis) { Commander.call(this); this.redis = redis; this.isCluster = this.redis.constructor.name === 'Cluster'; this.options = redis.options; this._queue = []; this._result = []; this._transactions = 0; this._shaToScript = {}; var _this = this; _.keys(redis.scriptsSet).forEach(function (name) { var script = redis.scriptsSet[name]; _this._shaToScript[script.sha] = script; _this[name] = redis[name]; _this[name + 'Buffer'] = redis[name + 'Buffer']; }); this.promise = new Promise(function (resolve, reject) { _this.resolve = resolve; _this.reject = reject; }); }
...
});
```
## Pipelining
If you want to send a batch of commands (e.g. > 5), you can use pipelining to queue
the commands in memory and then send them to Redis all at once. This way the performance improves by 50%~300% (See [benchmark section
](#benchmark)).
`redis.pipeline()` creates a `Pipeline` instance. You can call any Redis
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
...
addBatch = function (commands) { for (var i = 0; i < commands.length; ++i) { var command = commands[i]; var commandName = command.shift(); this[commandName].apply(this, command); } return this; }
...
var Pipeline = require('./pipeline');
var utils = require('./utils');
exports.addTransactionSupport = function (redis) {
redis.pipeline = function (commands) {
var pipeline = new Pipeline(this);
if (Array.isArray(commands)) {
pipeline.addBatch(commands);
}
return pipeline;
};
var multi = redis.multi;
redis.multi = function (commands, options) {
if (typeof options === 'undefined' && !Array.isArray(commands)) {
...
append = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
appendBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
asking = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
key = nodeKeys[0];
}
redis = _this.connectionPool.nodes.all[key];
}
}
if (asking) {
redis = _this.connectionPool.nodes.all[asking];
redis.asking();
}
}
if (!redis) {
redis = _.sample(_this.connectionPool.nodes[to]) ||
_.sample(_this.connectionPool.nodes.all);
}
}
...
askingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
auth = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
self.setStatus('connect');
self.resetCommandQueue();
// AUTH command should be processed before any other commands
var flushed = false;
if (self.condition.auth) {
self.auth(self.condition.auth, function (err) {
if (err) {
if (err.message.indexOf('no password is set') === -1) {
flushed = true;
self.flushQueue(err);
self.silentEmit('error', err);
self.disconnect(true);
} else {
...
authBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgrewriteaof = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgrewriteaofBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgsave = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgsaveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitfield = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitfieldBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitpos = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitposBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
blpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
blpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpoplpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpoplpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
call = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
var fbuffer = require('flexbuffer');
var Promise = require('bluebird');
var util = require('util');
var commands = require('redis-commands');
var calculateSlot = require('cluster-key-slot');
function Pipeline(redis) {
Commander.call(this);
this.redis = redis;
this.isCluster = this.redis.constructor.name === 'Cluster';
this.options = redis.options;
this._queue = [];
this._result = [];
this._transactions = 0;
...
callBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
client = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
return;
}
var item;
var finalSelect = self.prevCondition ? self.prevCondition.select : self.condition.select;
if (self.options.connectionName) {
debug('set the connection name [%s]', self.options.connectionName);
self.client('setname', self.options.connectionName);
}
if (self.options.readOnly) {
debug('set the connection to readonly mode');
self.readonly().catch(_.noop);
}
...
clientBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
cluster = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
};
Cluster.prototype.getInfoFromNode = function (redis, callback) {
if (!redis) {
return callback(new Error('Node is disconnected'));
}
var _this = this;
redis.cluster('slots', utils.timeout(function (err, result) {
if (err) {
redis.disconnect();
return callback(err);
}
var nodes = [];
for (var i = 0; i < result.length; ++i) {
...
clusterBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
command = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
commandBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
config = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
configBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
createBuiltinCommand = function (commandName) { return { string: generateFunction(commandName, 'utf8'), buffer: generateFunction(commandName, null) }; }
n/a
dbsize = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
dbsizeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
debug = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
debugBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
defineCommand = function (name, definition) { var script = new Script(definition.lua, definition.numberOfKeys, this.options.keyPrefix); this.scriptsSet[name] = script; this[name] = generateScriptingFunction(script, 'utf8'); this[name + 'Buffer'] = generateScriptingFunction(script, null); }
...
care of script caching and to detect when to use `EVAL` and when to use `EVALSHA`.
ioredis expose a `defineCommand` method to make scripting much easier to use:
```javascript
var redis = new Redis();
// This will define a command echo:
redis.defineCommand('echo', {
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (err, result) {
...
del = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
`redis.pipeline()` creates a `Pipeline` instance. You can call any Redis
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
pipeline.exec(function (err, results) {
// `err` is always null, and `results` is an array of responses
// corresponding to the sequence of queued commands.
// Each response follows the format `[err, result]`.
});
// You can even chain the commands:
...
delBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
discard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
discardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
dump = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
dumpBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
echo = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
redis.defineCommand('echo', {
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (
err, result) {
// result === ['k1', 'k2', 'a1', 'a2']
});
// `echoBuffer` is also defined automatically to return buffers instead of strings:
redis.echoBuffer('k1', 'k2', 'a1', 'a2', function (err, result) {
// result[0] === new Buffer('k1');
});
...
echoBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (err, result) {
// result === ['k1', 'k2', 'a1', 'a2']
});
// `echoBuffer` is also defined automatically to return buffers instead of strings:
redis.echoBuffer('k1', 'k2', 'a1', 'a2', function
(err, result) {
// result[0] === new Buffer('k1');
});
// And of course it works with pipeline:
redis.pipeline().set('foo', 'bar').echo('k1', 'k2', 'a1', 'a2').exec
();
```
...
eval = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalsha = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalshaBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
exec = function (callback) { if (this._transactions > 0) { this._transactions -= 1; return (this.options.dropBufferSupport ? exec : execBuffer).apply(this, arguments); } if (!this.nodeifiedPromise) { this.nodeifiedPromise = true; this.promise.nodeify(callback); } if (_.isEmpty(this._queue)) { this.resolve([]); } var pipelineSlot, i; if (this.isCluster) { // List of the first key for each command var sampleKeys = []; for (i = 0; i < this._queue.length; i++) { var keys = this._queue[i].getKeys(); if (keys.length) { sampleKeys.push(keys[0]); } } if (sampleKeys.length) { pipelineSlot = calculateSlot.generateMulti(sampleKeys); if (pipelineSlot < 0) { this.reject(new Error('All keys in the pipeline should belong to the same slot')); return this.promise; } } else { // Send the pipeline to a random node pipelineSlot = Math.random() * 16384 | 0; } } // Check whether scripts exists var scripts = []; for (i = 0; i < this._queue.length; ++i) { var item = this._queue[i]; if (this.isCluster && item.isCustomCommand) { this.reject(new Error('Sending custom commands in pipeline is not supported in Cluster mode.')); return this.promise; } if (item.name !== 'evalsha') { continue; } var script = this._shaToScript[item.args[0]]; if (!script) { continue; } scripts.push(script); } var _this = this; if (!scripts.length) { return execPipeline(); } return this.redis.script('exists', scripts.map(function (item) { return item.sha; })).then(function (results) { var pending = []; for (var i = 0; i < results.length; ++i) { if (!results[i]) { pending.push(scripts[i]); } } return Promise.all(pending.map(function (script) { return _this.redis.script('load', script.lua); })); }).then(execPipeline); function execPipeline() { var data = ''; var writePending = _this.replyPending = _this._queue.length; var node; if (_this.isCluster) { node = { slot: pipelineSlot, redis: _this.redis.connectionPool.nodes.all[_this.preferKey] }; } var bufferMode = false; var stream = { write: function (writable) { if (writable instanceof Buffer) { bufferMode = true; } if (bufferMode) { if (typeof data === 'string') { var flexBuffer = new fbuffer.FlexBuffer(0); flexBuffer.write(data); data = flexBuffer; } data.write(writable); } else { data += writable; } if (!--writePending) { if (bufferMode) { data = data.getBuffer(); } if (_this.isCluster) { node.redis.stream.write(data); } else { _this.redis.stream.write(data); } // Reset writePending for resending writePending = _this._queue.length; data = ''; bufferMode = false; } } }; for (var i = 0; i < _this._queue.length; ++i) { _this.redis.sendCommand(_this._queue[i], stream, node); } return _this.promise; } }
...
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
pipeline.exec(function (err, results) {
// `err` is always null, and `results` is an array of responses
// corresponding to the sequence of queued commands.
// Each response follows the format `[err, result]`.
});
// You can even chain the commands:
redis.pipeline().set('foo', 'bar').del('cc').exec(function (err, results) {
...
function deprecated() { warned = exports.printDeprecationMessage(msg, warned, deprecated); if (new.target) { return Reflect.construct(fn, arguments, new.target); } return fn.apply(this, arguments); }
n/a
exists = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
if (typeof this._keys === 'undefined') {
if (typeof transform !== 'function') {
transform = function (key) {
return key;
};
}
this._keys = [];
if (commands.exists(this.name)) {
var keyIndexes = commands.getKeyIndexes(this.name, this.args);
for (var i = 0; i < keyIndexes.length; i++) {
var index = keyIndexes[i];
this.args[index] = transform(this.args[index]);
this._keys.push(this.args[index]);
}
}
...
existsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expire = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
fillResult = function (value, position) { var i; if (this._queue[position].name === 'exec' && Array.isArray(value[1])) { var execLength = value[1].length; for (i = 0; i < execLength; i++) { if (value[1][i] instanceof Error) { continue; } var cmd = this._queue[position - (execLength - i)]; try { value[1][i] = cmd.transformReply(value[1][i]); } catch (err) { value[1][i] = err; } } } this._result[position] = value; if (--this.replyPending) { return; } if (this.isCluster) { var retriable = true; var commonError; var inTransaction; for (i = 0; i < this._result.length; ++i) { var error = this._result[i][0]; var command = this._queue[i]; if (command.name === 'multi') { inTransaction = true; } else if (command.name === 'exec') { inTransaction = false; } if (error) { if (command.name === 'exec' && error.message === 'EXECABORT Transaction discarded because of previous errors.') { continue; } if (!commonError) { commonError = { name: error.name, message: error.message }; } else if (commonError.name !== error.name || commonError.message !== error.message) { retriable = false; break; } } else if (!inTransaction) { var isReadOnly = commands.exists(command.name) && commands.hasFlag(command.name, 'readonly'); if (!isReadOnly) { retriable = false; break; } } } if (commonError && retriable) { var _this = this; var errv = commonError.message.split(' '); var queue = this._queue; inTransaction = false; this._queue = []; for (i = 0; i < queue.length; ++i) { if (errv[0] === 'ASK' && !inTransaction && queue[i].name !== 'asking' && (!queue[i - 1] || queue[i - 1].name !== 'asking')) { var asking = new Command('asking'); asking.ignore = true; this.sendCommand(asking); } queue[i].initPromise(); this.sendCommand(queue[i]); if (queue[i].name === 'multi') { inTransaction = true; } else if (queue[i].name === 'exec') { inTransaction = false; } } var matched = true; if (typeof this.leftRedirections === 'undefined') { this.leftRedirections = {}; } var exec = function () { _this.exec(); }; this.redis.handleError(commonError, this.leftRedirections, { moved: function (slot, key) { _this.preferKey = key; _this.redis.slots[errv[1]] = [key]; _this.redis.refreshSlotsCache(); _this.exec(); }, ask: function (slot, key) { _this.preferKey = key; _this.exec(); }, tryagain: exec, clusterDown: exec, connectionClosed: exec, maxRedirections: function () { matched = false; }, defaults: function () { matched = false; } }); if (matched) { return; } } } var ignoredCount = 0; for (i = 0; i < this._queue.length - ignoredCount; ++i) { if (this._queue[i + ignoredCount].ignore) { ignoredCount += 1; } this._result[i] = this._result[i + ignoredCount]; } this.resolve(this._result.slice(0, this._result.length - ignoredCount)); }
...
Pipeline.prototype.sendCommand = function (command) {
var position = this._queue.length;
var _this = this;
command.promise.then(function (result) {
_this.fillResult([null, result], position);
}).catch(function (error) {
_this.fillResult([error], position);
});
this._queue.push(command);
return this;
...
flushall = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushallBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushdb = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
`Cluster#nodes()` accepts a parameter role, which can be "master", "slave" and "all" (default), and
returns an array of `Redis` instance. For example:
```javascript
// Send `FLUSHDB` command to all slaves:
var slaves = cluster.nodes('slave');
Promise.all(slaves.map(function (node) {
return node.flushdb();
}));
// Get keys of all the masters:
var masters = cluster.nodes('master');
Promise.all(masters.map(function (node) {
return node.keys();
})).then(function (keys) {
...
flushdbBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geodist = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geodistBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geohash = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geohashBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geopos = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoposBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadius = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusbymember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusbymemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
get = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
## Basic Usage
```javascript
var Redis = require('ioredis');
var redis = new Redis();
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
...
getBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
redis.set('foo', new Buffer('bar'));
```
And every command has a method that returns a Buffer (by adding a suffix of "Buffer" to the command name).
To get a buffer instead of a utf8 string:
```javascript
redis.getBuffer('foo', function (err, result) {
// result is a buffer.
});
```
## Pipelining
If you want to send a batch of commands (e.g. > 5), you can use pipelining to queue
the commands in memory and then send them to Redis all at once. This way the performance improves by 50%~300% (See [benchmark section
](#benchmark)).
...
getBuiltinCommands = function () { return _.clone(commands); }
n/a
getbit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getbitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hdel = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hdelBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hexists = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hexistsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetall = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetallBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyfloat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyfloatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hkeys = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hkeysBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hstrlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hstrlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hvals = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hvalsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyfloat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyfloatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
info = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
* process commands.
*
* @param {Function} callback
* @private
*/
Redis.prototype._readyCheck = function (callback) {
var _this = this;
this.info(function (err, res) {
if (err) {
return callback(err);
}
if (typeof res !== 'string') {
return callback(null, res);
}
...
infoBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
keys = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
Promise.all(slaves.map(function (node) {
return node.flushdb();
}));
// Get keys of all the masters:
var masters = cluster.nodes('master');
Promise.all(masters.map(function (node) {
return node.keys();
})).then(function (keys) {
// keys: [['key1', 'key2'], ['key3', 'key4']]
});
```
### Transaction and pipeline in Cluster mode
Almost all features that are supported by `Redis` are also supported by `Redis.Cluster`, e.g. custom commands, transaction and pipeline
.
...
keysBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lastsave = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lastsaveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
latency = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
latencyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lindex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lindexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
linsert = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
linsertBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
llen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
llenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ltrim = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ltrimBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
memory = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
memoryBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
migrate = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
migrateBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
module = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
moduleBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
move = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
moveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
```
There are three built-in transformers, two argument transformers for `hmset` & `mset` and
a reply transformer for `hgetall`. Transformers for `hmset` and `hgetall` were mentioned
above, and the transformer for `mset` is similar to the one for `hmset`:
```javascript
redis.mset({ k1: 'v1', k2: 'v2' });
redis.get('k1', function (err, result) {
// result === 'v1';
});
redis.mset(new Map([['k3', 'v3'], ['k4', 'v4']]));
redis.get('k3', function (err, result) {
// result === 'v3';
...
msetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
msetnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
msetnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
multi = function () { this._transactions += 1; return multi.apply(this, arguments); }
...
## Transaction
Most of the time, the transaction commands `multi` & `exec` are used together with pipeline.
Therefore, when `multi` is called, a `Pipeline` instance is created automatically by default,
so you can use `multi` just like `pipeline`:
```javascript
redis.multi().set('foo', 'bar').get('foo').exec(function
(err, results) {
// results === [[null, 'OK'], [null, 'bar']]
});
```
If there's a syntax error in the transaction's command chain (e.g. wrong number of arguments, wrong command name, etc),
then none of the commands would be executed, and an error is returned:
```javascript
...
multiBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
object = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
objectBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
persist = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
persistBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpire = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfdebug = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfdebugBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfmerge = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfmergeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfselftest = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfselftestBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ping = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
post = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
postBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psetex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psetexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Both `channel` and `message` are buffers.
});
```
`PSUBSCRIBE` is also supported in a similar way:
```javascript
redis.psubscribe('pat?ern', function (err, count) {});
redis.on('pmessage', function (pattern, channel, message) {});
redis.on('pmessageBuffer', function (pattern, channel, message) {});
```
When a client issues a SUBSCRIBE or PSUBSCRIBE, that connection is put into a "subscriber" mode.
At that point, only commands that modify the subscription set are valid.
When the subscription set is empty, the connection is put back into regular mode.
...
psubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psync = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psyncBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pttl = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pttlBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
publish = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
var Redis = require('ioredis');
var redis = new Redis();
var pub = new Redis();
redis.subscribe('news', 'music', function (err, count) {
// Now we are subscribed to both the 'news' and 'music' channels.
// `count` represents the number of channels we are currently subscribed to.
pub.publish('news', 'Hello world!');
pub.publish('music', 'Hello again!');
});
redis.on('message', function (channel, message) {
// Receive message Hello world! from channel news
// Receive message Hello again! from channel music
console.log('Receive message %s from channel %s', message, channel);
...
publishBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pubsub = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pubsubBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
punsubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
punsubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
quit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
});
```
You can learn more from the [Redis documentation](http://redis.io/commands/scan).
## Auto-reconnect
By default, ioredis will try to reconnect when the connection to Redis is lost
except when the connection is closed manually by `redis.disconnect()` or `redis.quit()`.
It's very flexible to control how long to wait to reconnect after disconnection
using the `retryStrategy` option:
```javascript
var redis = new Redis({
// This is the default value of `retryStrategy`
...
quitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
randomkey = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
randomkeyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readonly = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
if (self.options.connectionName) {
debug('set the connection name [%s]', self.options.connectionName);
self.client('setname', self.options.connectionName);
}
if (self.options.readOnly) {
debug('set the connection to readonly mode');
self.readonly().catch(_.noop);
}
if (self.prevCondition) {
var condition = self.prevCondition;
self.prevCondition = null;
if (condition.subscriber && self.options.autoResubscribe) {
// We re-select the previous db first since
...
readonlyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readwrite = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readwriteBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rename = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renameBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renamenx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renamenxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
replconf = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
replconfBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restore-asking = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restore-askingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
role = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
roleBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpoplpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpoplpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
// Arguments to commands are flattened, so the following are the same:
redis.sadd('set', 1, 3, 5, 7);
redis.sadd('set', [1, 3, 5, 7]);
// All arguments are passed directly to the redis server:
redis.set('key', 100, 'EX', 10);
```
See the `examples/` folder for more examples.
...
saddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
save = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
saveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
script = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
}
var _this = this;
if (!scripts.length) {
return execPipeline();
}
return this.redis.script('exists', scripts.map(function (item) {
return item.sha;
})).then(function (results) {
var pending = [];
for (var i = 0; i < results.length; ++i) {
if (!results[i]) {
pending.push(scripts[i]);
}
...
scriptBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiff = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
select = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
console.warn('[WARN] Redis server does not require a password, but a password was supplied.');
}
}
});
}
if (self.condition.select) {
self.select(self.condition.select);
}
if (!self.options.enableReadyCheck) {
exports.readyHandler(self)();
}
self.initParser();
...
selectBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sendCommand = function (command) { var position = this._queue.length; var _this = this; command.promise.then(function (result) { _this.fillResult([null, result], position); }).catch(function (error) { _this.fillResult([error], position); }); this._queue.push(command); return this; }
...
if (this.options.showFriendlyErrorStack) {
options.errorStack = new Error().stack;
}
if (this.options.keyPrefix) {
options.keyPrefix = this.options.keyPrefix;
}
return this.sendCommand(new Command(commandName, args, options, callback));
};
}
function generateScriptingFunction(_script, _encoding) {
return function () {
var length = arguments.length;
var lastArgIndex = length - 1;
...
send_command = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sentinel = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
}
});
}
};
SentinelConnector.prototype.updateSentinels = function (client, callback) {
var _this = this;
client.sentinel('sentinels', this.options.name, function (err, result) {
if (err) {
client.disconnect();
return callback(err);
}
if (Array.isArray(result)) {
for (var i = 0; i < result.length; ++i) {
var sentinel = utils.packObject(result[i]);
...
sentinelBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
set = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
## Basic Usage
```javascript
var Redis = require('ioredis');
var redis = new Redis();
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
...
setBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setbit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setbitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
shutdown = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
shutdownBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinter = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sismember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sismemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slaveof = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slaveofBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slowlog = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slowlogBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smembers = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smembersBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smove = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smoveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sort = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Works well with pipelining/transaction
fooRedis.pipeline()
// Sends SORT foo:list BY foo:weight_*->fieldname
.sort('list', 'BY', 'weight_*->fieldname')
// Supports custom commands
// Sends EVALSHA xxx foo:k1 foo:k2 a1 a2
.echo('k1', 'k2', 'a1', 'a2')
.exec()
```
## Transforming Arguments & Replies
...
sortBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
spop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
spopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srandmember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srandmemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
strlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
strlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
subscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
It subscribes to a channel with one connection
and publishes to that channel with the other:
```javascript
var Redis = require('ioredis');
var redis = new Redis();
var pub = new Redis();
redis.subscribe('news', 'music', function (err, count) {
// Now we are subscribed to both the 'news' and 'music' channels.
// `count` represents the number of channels we are currently subscribed to.
pub.publish('news', 'Hello world!');
pub.publish('music', 'Hello again!');
});
...
subscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
substr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
substrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunion = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
swapdb = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
swapdbBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sync = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
syncBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
time = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
timeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
touch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
touchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ttl = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ttlBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
type = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
typeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unlink = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unlinkBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unsubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unsubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unwatch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unwatchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
wait = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
waitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
watch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
watchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zincrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zincrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zinterstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zinterstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zlexcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zlexcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zunionstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zunionstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
function Redis() { if (!(this instanceof Redis)) { return new Redis(arguments[0], arguments[1], arguments[2]); } EventEmitter.call(this); Commander.call(this); this.parseOptions(arguments[0], arguments[1], arguments[2]); this.resetCommandQueue(); this.resetOfflineQueue(); if (this.options.sentinels) { this.connector = new SentinelConnector(this.options); } else { this.connector = new Connector(this.options); } this.retryAttempts = 0; // end(or wait) -> connecting -> connect -> ready -> end if (this.options.lazyConnect) { this.setStatus('wait'); } else { this.connect().catch(_.noop); } }
n/a
function Cluster(startupNodes, options) { EventEmitter.call(this); Commander.call(this); this.options = _.defaults(this.options, options, Cluster.defaultOptions); // validate options if (typeof this.options.scaleReads !== 'function' && ['all', 'master', 'slave'].indexOf(this.options.scaleReads) === -1) { throw new Error('Invalid option scaleReads "' + this.options.scaleReads + '". Expected "all", "master", "slave" or a custom function'); } this.connectionPool = new ConnectionPool(this.options.redisOptions); this.startupNodes = startupNodes; var _this = this; this.connectionPool.on('-node', function (redis) { if (_this.status !== 'disconnecting' && _this.subscriber === redis) { _this.selectSubscriber(); } _this.emit('-node', redis); }); this.connectionPool.on('+node', function (redis) { _this.emit('+node', redis); }); this.connectionPool.on('drain', function () { _this.setStatus('close'); }); this.connectionPool.on('nodeError', function (error) { _this.emit('node error', error); }); this.slots = []; this.retryAttempts = 0; this.resetOfflineQueue(); this.delayQueue = new DelayQueue(); this.subscriber = null; if (this.options.lazyConnect) { this.setStatus('wait'); } else { this.connect().catch(_.noop); } }
...
## Cluster
Redis Cluster provides a way to run a Redis installation where data is automatically sharded across multiple Redis nodes.
You can connect to a Redis Cluster like this:
```javascript
var Redis = require('ioredis');
var cluster = new Redis.Cluster([{
port: 6380,
host: '127.0.0.1'
}, {
port: 6381,
host: '127.0.0.1'
}]);
...
function Command(name, args, options, callback) { if (typeof options === 'undefined') { options = {}; } this.name = name; this.replyEncoding = options.replyEncoding; this.errorStack = options.errorStack; this.args = args ? _.flatten(args) : []; this.callback = callback; this.initPromise(); var keyPrefix = options.keyPrefix; if (keyPrefix) { this._iterateKeys(function (key) { return keyPrefix + key; }); } }
n/a
function Promise(executor) { if (executor !== INTERNAL) { check(this, executor); } this._bitField = 0; this._fulfillmentHandler0 = undefined; this._rejectionHandler0 = undefined; this._promise0 = undefined; this._receiver0 = undefined; this._resolveFromExecutor(executor); this._promiseCreated(); this._fireEvent("promiseCreated", this); }
n/a
function ReplyError(message) { Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.message = message; }
n/a
createClient = function () { return Redis.apply(this, arguments); }
n/a
print = function (err, reply) { if (err) { console.log('Error: ' + err); } else { console.log('Reply: ' + reply); } }
n/a
function EventEmitter() { EventEmitter.init.call(this); }
n/a
_readyCheck = function (callback) { var _this = this; this.info(function (err, res) { if (err) { return callback(err); } if (typeof res !== 'string') { return callback(null, res); } var info = {}; var lines = res.split('\r\n'); for (var i = 0; i < lines.length; ++i) { var parts = lines[i].split(':'); if (parts[1]) { info[parts[0]] = parts[1]; } } if (!info.loading || info.loading === '0') { callback(null, info); } else { var retryTime = (info.loading_eta_seconds || 1) * 1000; debug('Redis server still loading, trying again in ' + retryTime + 'ms'); setTimeout(function () { _this._readyCheck(callback); }, retryTime); } }); }
...
if (!info.loading || info.loading === '0') {
callback(null, info);
} else {
var retryTime = (info.loading_eta_seconds || 1) * 1000;
debug('Redis server still loading, trying again in ' + retryTime + 'ms');
setTimeout(function () {
_this._readyCheck(callback);
}, retryTime);
}
});
};
/**
* Emit only when there's at least one listener.
...
append = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
appendBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
asking = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
key = nodeKeys[0];
}
redis = _this.connectionPool.nodes.all[key];
}
}
if (asking) {
redis = _this.connectionPool.nodes.all[asking];
redis.asking();
}
}
if (!redis) {
redis = _.sample(_this.connectionPool.nodes[to]) ||
_.sample(_this.connectionPool.nodes.all);
}
}
...
askingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
auth = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
self.setStatus('connect');
self.resetCommandQueue();
// AUTH command should be processed before any other commands
var flushed = false;
if (self.condition.auth) {
self.auth(self.condition.auth, function (err) {
if (err) {
if (err.message.indexOf('no password is set') === -1) {
flushed = true;
self.flushQueue(err);
self.silentEmit('error', err);
self.disconnect(true);
} else {
...
authBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgrewriteaof = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgrewriteaofBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgsave = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bgsaveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitfield = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitfieldBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitpos = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
bitposBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
blpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
blpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpoplpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
brpoplpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
call = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
var fbuffer = require('flexbuffer');
var Promise = require('bluebird');
var util = require('util');
var commands = require('redis-commands');
var calculateSlot = require('cluster-key-slot');
function Pipeline(redis) {
Commander.call(this);
this.redis = redis;
this.isCluster = this.redis.constructor.name === 'Cluster';
this.options = redis.options;
this._queue = [];
this._result = [];
this._transactions = 0;
...
callBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
client = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
return;
}
var item;
var finalSelect = self.prevCondition ? self.prevCondition.select : self.condition.select;
if (self.options.connectionName) {
debug('set the connection name [%s]', self.options.connectionName);
self.client('setname', self.options.connectionName);
}
if (self.options.readOnly) {
debug('set the connection to readonly mode');
self.readonly().catch(_.noop);
}
...
clientBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
cluster = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
};
Cluster.prototype.getInfoFromNode = function (redis, callback) {
if (!redis) {
return callback(new Error('Node is disconnected'));
}
var _this = this;
redis.cluster('slots', utils.timeout(function (err, result) {
if (err) {
redis.disconnect();
return callback(err);
}
var nodes = [];
for (var i = 0; i < result.length; ++i) {
...
clusterBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
command = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
commandBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
config = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
configBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
connect = function (callback) { return new Promise(function (resolve, reject) { if (this.status === 'connecting' || this.status === 'connect' || this.status === 'ready') { reject(new Error('Redis is already connecting/connected')); return; } this.setStatus('connecting'); this.condition = { select: this.options.db, auth: this.options.password, subscriber: false }; var _this = this; this.connector.connect(function (err, stream) { if (err) { _this.flushQueue(err); _this.silentEmit('error', err); reject(err); _this.setStatus('end'); return; } var CONNECT_EVENT = _this.options.tls ? 'secureConnect' : 'connect'; _this.stream = stream; if (typeof _this.options.keepAlive === 'number') { stream.setKeepAlive(true, _this.options.keepAlive); } stream.once(CONNECT_EVENT, eventHandler.connectHandler(_this)); stream.once('error', eventHandler.errorHandler(_this)); stream.once('close', eventHandler.closeHandler(_this)); stream.on('data', eventHandler.dataHandler(_this)); if (_this.options.connectTimeout) { stream.setTimeout(_this.options.connectTimeout, function () { stream.setTimeout(0); stream.destroy(); var err = new Error('connect ETIMEDOUT'); err.errorno = 'ETIMEDOUT'; err.code = 'ETIMEDOUT'; err.syscall = 'connect'; eventHandler.errorHandler(_this)(err); }); stream.once(CONNECT_EVENT, function () { stream.setTimeout(0); }); } if (_this.options.noDelay) { stream.setNoDelay(true); } var connectionConnectHandler = function () { _this.removeListener('close', connectionCloseHandler); resolve(); }; var connectionCloseHandler = function () { _this.removeListener(CONNECT_EVENT, connectionConnectHandler); reject(new Error(utils.CONNECTION_CLOSED_ERROR_MSG)); }; _this.once(CONNECT_EVENT, connectionConnectHandler); _this.once('close', connectionCloseHandler); }); }.bind(this)).nodeify(callback); }
...
});
```
`retryStrategy` is a function that will be called when the connection is lost.
The argument `times` means this is the nth reconnection being made and
the return value represents how long (in ms) to wait to reconnect. When the
return value isn't a number, ioredis will stop trying to reconnect, and the connection
will be lost forever if the user doesn't call `redis.connect()` manually.
When reconnected, the client will auto subscribe to channels that the previous connection subscribed to.
This behavior can be disabled by setting the `autoResubscribe` option to `false`.
And if the previous connection has some unfulfilled commands (most likely blocking commands such as `brpop` and `blpop`),
the client will resend them when reconnected. This behavior can be disabled by setting the `autoResendUnfulfilledCommands` option
to `false`.
...
createBuiltinCommand = function (commandName) { return { string: generateFunction(commandName, 'utf8'), buffer: generateFunction(commandName, null) }; }
n/a
dbsize = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
dbsizeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
debug = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
debugBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
decrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
defineCommand = function (name, definition) { var script = new Script(definition.lua, definition.numberOfKeys, this.options.keyPrefix); this.scriptsSet[name] = script; this[name] = generateScriptingFunction(script, 'utf8'); this[name + 'Buffer'] = generateScriptingFunction(script, null); }
...
care of script caching and to detect when to use `EVAL` and when to use `EVALSHA`.
ioredis expose a `defineCommand` method to make scripting much easier to use:
```javascript
var redis = new Redis();
// This will define a command echo:
redis.defineCommand('echo', {
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (err, result) {
...
del = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
`redis.pipeline()` creates a `Pipeline` instance. You can call any Redis
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
pipeline.exec(function (err, results) {
// `err` is always null, and `results` is an array of responses
// corresponding to the sequence of queued commands.
// Each response follows the format `[err, result]`.
});
// You can even chain the commands:
...
delBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
discard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
discardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
disconnect = function (reconnect) { if (!reconnect) { this.manuallyClosing = true; } if (this.reconnectTimeout) { clearTimeout(this.reconnectTimeout); this.reconnectTimeout = null; } if (this.status === 'wait') { eventHandler.closeHandler(this)(); } else { this.connector.disconnect(); } }
...
});
```
You can learn more from the [Redis documentation](http://redis.io/commands/scan).
## Auto-reconnect
By default, ioredis will try to reconnect when the connection to Redis is lost
except when the connection is closed manually by `redis.disconnect()` or `redis.quit()`.
It's very flexible to control how long to wait to reconnect after disconnection
using the `retryStrategy` option:
```javascript
var redis = new Redis({
// This is the default value of `retryStrategy`
...
dump = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
dumpBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
duplicate = function (override) { return new Redis(_.assign(_.cloneDeep(this.options), override || {})); }
...
/**
* Create a new instance with the same options as the current one.
*
* @example
* ```js
* var redis = new Redis(6380);
* var anotherRedis = redis.duplicate();
* ```
*
* @public
*/
Redis.prototype.duplicate = function (override) {
return new Redis(_.assign(_.cloneDeep(this.options), override || {}));
};
...
echo = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
redis.defineCommand('echo', {
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (
err, result) {
// result === ['k1', 'k2', 'a1', 'a2']
});
// `echoBuffer` is also defined automatically to return buffers instead of strings:
redis.echoBuffer('k1', 'k2', 'a1', 'a2', function (err, result) {
// result[0] === new Buffer('k1');
});
...
echoBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Now `echo` can be used just like any other ordinary command,
// and ioredis will try to use `EVALSHA` internally when possible for better performance.
redis.echo('k1', 'k2', 'a1', 'a2', function (err, result) {
// result === ['k1', 'k2', 'a1', 'a2']
});
// `echoBuffer` is also defined automatically to return buffers instead of strings:
redis.echoBuffer('k1', 'k2', 'a1', 'a2', function
(err, result) {
// result[0] === new Buffer('k1');
});
// And of course it works with pipeline:
redis.pipeline().set('foo', 'bar').echo('k1', 'k2', 'a1', 'a2').exec
();
```
...
end = function () { this.disconnect(); }
...
Connector.prototype.check = function () {
return true;
};
Connector.prototype.disconnect = function () {
this.connecting = false;
if (this.stream) {
this.stream.end();
}
};
Connector.prototype.connect = function (callback) {
this.connecting = true;
var connectionOptions;
if (this.options.path) {
...
eval = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalsha = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
evalshaBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
exec = function (callback) { return exec.call(this).then(function (results) { if (Array.isArray(results)) { results = utils.wrapMultiResult(results); } return results; }).nodeify(callback); }
...
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
pipeline.exec(function (err, results) {
// `err` is always null, and `results` is an array of responses
// corresponding to the sequence of queued commands.
// Each response follows the format `[err, result]`.
});
// You can even chain the commands:
redis.pipeline().set('foo', 'bar').del('cc').exec(function (err, results) {
...
execBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
exists = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
if (typeof this._keys === 'undefined') {
if (typeof transform !== 'function') {
transform = function (key) {
return key;
};
}
this._keys = [];
if (commands.exists(this.name)) {
var keyIndexes = commands.getKeyIndexes(this.name, this.args);
for (var i = 0; i < keyIndexes.length; i++) {
var index = keyIndexes[i];
this.args[index] = transform(this.args[index]);
this._keys.push(this.args[index]);
}
}
...
existsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expire = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
expireatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushQueue = function (error, options) { options = _.defaults({}, options, { offlineQueue: true, commandQueue: true }); var item; if (options.offlineQueue) { while (this.offlineQueue.length > 0) { item = this.offlineQueue.shift(); item.command.reject(error); } } if (options.commandQueue) { if (this.commandQueue.length > 0) { if (this.stream) { this.stream.removeAllListeners('data'); } while (this.commandQueue.length > 0) { item = this.commandQueue.shift(); item.command.reject(error); } } } }
...
auth: this.options.password,
subscriber: false
};
var _this = this;
this.connector.connect(function (err, stream) {
if (err) {
_this.flushQueue(err);
_this.silentEmit('error', err);
reject(err);
_this.setStatus('end');
return;
}
var CONNECT_EVENT = _this.options.tls ? 'secureConnect' : 'connect';
...
flushall = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushallBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
flushdb = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
`Cluster#nodes()` accepts a parameter role, which can be "master", "slave" and "all" (default), and
returns an array of `Redis` instance. For example:
```javascript
// Send `FLUSHDB` command to all slaves:
var slaves = cluster.nodes('slave');
Promise.all(slaves.map(function (node) {
return node.flushdb();
}));
// Get keys of all the masters:
var masters = cluster.nodes('master');
Promise.all(masters.map(function (node) {
return node.keys();
})).then(function (keys) {
...
flushdbBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geodist = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geodistBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geohash = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geohashBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geopos = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
geoposBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadius = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusbymember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
georadiusbymemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
get = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
## Basic Usage
```javascript
var Redis = require('ioredis');
var redis = new Redis();
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
...
getBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
redis.set('foo', new Buffer('bar'));
```
And every command has a method that returns a Buffer (by adding a suffix of "Buffer" to the command name).
To get a buffer instead of a utf8 string:
```javascript
redis.getBuffer('foo', function (err, result) {
// result is a buffer.
});
```
## Pipelining
If you want to send a batch of commands (e.g. > 5), you can use pipelining to queue
the commands in memory and then send them to Redis all at once. This way the performance improves by 50%~300% (See [benchmark section
](#benchmark)).
...
getBuiltinCommands = function () { return _.clone(commands); }
n/a
getbit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getbitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
getsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hdel = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hdelBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hexists = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hexistsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetall = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hgetallBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyfloat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hincrbyfloatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hkeys = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hkeysBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hmsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hscanBufferStream = function (key, options) { if (command === 'scan' || command === 'scanBuffer') { options = key; key = null; } return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
hscanStream = function (key, options) { if (command === 'scan' || command === 'scanBuffer') { options = key; key = null; } return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
...
Just like other commands, `scanStream` has a binary version `scanBufferStream`, which returns an array of buffers. It's useful
when
the key names are not utf8 strings.
There are also `hscanStream`, `zscanStream` and `sscanStream` to iterate through elements in a hash, zset and set. The interface
of each is
similar to `scanStream` except the first argument is the key name:
```javascript
var stream = redis.hscanStream('myhash', {
match: 'age:??'
});
```
You can learn more from the [Redis documentation](http://redis.io/commands/scan).
## Auto-reconnect
...
hset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hsetnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hstrlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hstrlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hvals = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
hvalsBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyfloat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
incrbyfloatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
info = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
* process commands.
*
* @param {Function} callback
* @private
*/
Redis.prototype._readyCheck = function (callback) {
var _this = this;
this.info(function (err, res) {
if (err) {
return callback(err);
}
if (typeof res !== 'string') {
return callback(null, res);
}
...
infoBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
initParser = function () { var _this = this; this.replyParser = new Parser({ name: this.options.parser, stringNumbers: this.options.stringNumbers, returnBuffers: !this.options.dropBufferSupport, returnError: function (err) { _this.returnError(new ReplyError(err.message)); }, returnReply: function (reply) { _this.returnReply(reply); }, returnFatalError: function (err) { _this.flushQueue(err, { offlineQueue: false }); _this.silentEmit('error', new Error('Redis parser fatal error: ' + err.stack)); _this.disconnect(true); } }); if (this.replyParser.name === 'hiredis' && !this.options.dropBufferSupport) { console.warn('[WARN] ioredis is using hiredis parser, however "dropBufferSupport" is disabled. ' + 'It\'s highly recommended to enable this option. ' + 'Refer to https://github.com/luin/ioredis/wiki/Improve-Performance for more details.'); } }
...
self.select(self.condition.select);
}
if (!self.options.enableReadyCheck) {
exports.readyHandler(self)();
}
self.initParser();
if (self.options.enableReadyCheck) {
self._readyCheck(function (err, info) {
if (err) {
if (!flushed) {
self.flushQueue(new Error('Ready check failed: ' + err.message));
self.silentEmit('error', err);
...
keys = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
Promise.all(slaves.map(function (node) {
return node.flushdb();
}));
// Get keys of all the masters:
var masters = cluster.nodes('master');
Promise.all(masters.map(function (node) {
return node.keys();
})).then(function (keys) {
// keys: [['key1', 'key2'], ['key3', 'key4']]
});
```
### Transaction and pipeline in Cluster mode
Almost all features that are supported by `Redis` are also supported by `Redis.Cluster`, e.g. custom commands, transaction and pipeline
.
...
keysBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lastsave = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lastsaveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
latency = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
latencyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lindex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lindexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
linsert = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
linsertBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
llen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
llenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lpushxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lrem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
lsetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ltrim = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ltrimBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
memory = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
memoryBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mget = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mgetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
migrate = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
migrateBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
module = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
moduleBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
monitor = function (callback) { var monitorInstance = this.duplicate({ monitor: true, lazyConnect: false }); return new Promise(function (resolve) { monitorInstance.once('monitoring', function () { resolve(monitorInstance); }); }).nodeify(callback); }
...
The `monitor` method returns a monitor instance.
After you send the MONITOR command, no other commands are valid on that connection. ioredis will emit a monitor event for every
new monitor message that comes across.
The callback for the monitor event takes a timestamp from the Redis server and an array of command arguments.
Here is a simple example:
```javascript
redis.monitor(function (err, monitor) {
monitor.on('monitor', function (time, args, source, database) {
});
});
```
## Streamify Scanning
Redis 2.8 added the `SCAN` command to incrementally iterate through the keys in the database. It's different from `KEYS` in
that
...
move = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
moveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
mset = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
```
There are three built-in transformers, two argument transformers for `hmset` & `mset` and
a reply transformer for `hgetall`. Transformers for `hmset` and `hgetall` were mentioned
above, and the transformer for `mset` is similar to the one for `hmset`:
```javascript
redis.mset({ k1: 'v1', k2: 'v2' });
redis.get('k1', function (err, result) {
// result === 'v1';
});
redis.mset(new Map([['k3', 'v3'], ['k4', 'v4']]));
redis.get('k3', function (err, result) {
// result === 'v3';
...
msetBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
msetnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
msetnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
multi = function (commands, options) { if (typeof options === 'undefined' && !Array.isArray(commands)) { options = commands; commands = null; } if (options && options.pipeline === false) { return multi.call(this); } var pipeline = new Pipeline(this); pipeline.multi(); if (Array.isArray(commands)) { pipeline.addBatch(commands); } var exec = pipeline.exec; pipeline.exec = function (callback) { if (this._transactions > 0) { exec.call(pipeline); } var promise = exec.call(pipeline); return promise.then(function (result) { var execResult = result[result.length - 1]; if (execResult[0]) { execResult[0].previousErrors = []; for (var i = 0; i < result.length - 1; ++i) { if (result[i][0]) { execResult[0].previousErrors.push(result[i][0]); } } throw execResult[0]; } return utils.wrapMultiResult(execResult[1]); }).nodeify(callback); }; var execBuffer = pipeline.execBuffer; pipeline.execBuffer = function (callback) { if (this._transactions > 0) { execBuffer.call(pipeline); } return pipeline.exec(callback); }; return pipeline; }
...
## Transaction
Most of the time, the transaction commands `multi` & `exec` are used together with pipeline.
Therefore, when `multi` is called, a `Pipeline` instance is created automatically by default,
so you can use `multi` just like `pipeline`:
```javascript
redis.multi().set('foo', 'bar').get('foo').exec(function
(err, results) {
// results === [[null, 'OK'], [null, 'bar']]
});
```
If there's a syntax error in the transaction's command chain (e.g. wrong number of arguments, wrong command name, etc),
then none of the commands would be executed, and an error is returned:
```javascript
...
multiBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
object = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
objectBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
parseOptions = function () { this.options = {}; for (var i = 0; i < arguments.length; ++i) { var arg = arguments[i]; if (arg === null || typeof arg === 'undefined') { continue; } if (typeof arg === 'object') { _.defaults(this.options, arg); } else if (typeof arg === 'string') { _.defaults(this.options, utils.parseURL(arg)); } else if (typeof arg === 'number') { this.options.port = arg; } else { throw new Error('Invalid argument ' + arg); } } _.defaults(this.options, Redis.defaultOptions); if (typeof this.options.port === 'string') { this.options.port = parseInt(this.options.port, 10); } if (typeof this.options.db === 'string') { this.options.db = parseInt(this.options.db, 10); } }
...
if (!(this instanceof Redis)) {
return new Redis(arguments[0], arguments[1], arguments[2]);
}
EventEmitter.call(this);
Commander.call(this);
this.parseOptions(arguments[0], arguments[1], arguments[2]);
this.resetCommandQueue();
this.resetOfflineQueue();
if (this.options.sentinels) {
this.connector = new SentinelConnector(this.options);
} else {
...
persist = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
persistBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpire = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireat = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pexpireatBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfdebug = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfdebugBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfmerge = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfmergeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfselftest = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pfselftestBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ping = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pipeline = function (commands) { var pipeline = new Pipeline(this); if (Array.isArray(commands)) { pipeline.addBatch(commands); } return pipeline; }
...
});
```
## Pipelining
If you want to send a batch of commands (e.g. > 5), you can use pipelining to queue
the commands in memory and then send them to Redis all at once. This way the performance improves by 50%~300% (See [benchmark section
](#benchmark)).
`redis.pipeline()` creates a `Pipeline` instance. You can call any Redis
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
...
post = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
postBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psetex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psetexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Both `channel` and `message` are buffers.
});
```
`PSUBSCRIBE` is also supported in a similar way:
```javascript
redis.psubscribe('pat?ern', function (err, count) {});
redis.on('pmessage', function (pattern, channel, message) {});
redis.on('pmessageBuffer', function (pattern, channel, message) {});
```
When a client issues a SUBSCRIBE or PSUBSCRIBE, that connection is put into a "subscriber" mode.
At that point, only commands that modify the subscription set are valid.
When the subscription set is empty, the connection is put back into regular mode.
...
psubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psync = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
psyncBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pttl = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pttlBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
publish = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
var Redis = require('ioredis');
var redis = new Redis();
var pub = new Redis();
redis.subscribe('news', 'music', function (err, count) {
// Now we are subscribed to both the 'news' and 'music' channels.
// `count` represents the number of channels we are currently subscribed to.
pub.publish('news', 'Hello world!');
pub.publish('music', 'Hello again!');
});
redis.on('message', function (channel, message) {
// Receive message Hello world! from channel news
// Receive message Hello again! from channel music
console.log('Receive message %s from channel %s', message, channel);
...
publishBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pubsub = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
pubsubBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
punsubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
punsubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
quit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
});
```
You can learn more from the [Redis documentation](http://redis.io/commands/scan).
## Auto-reconnect
By default, ioredis will try to reconnect when the connection to Redis is lost
except when the connection is closed manually by `redis.disconnect()` or `redis.quit()`.
It's very flexible to control how long to wait to reconnect after disconnection
using the `retryStrategy` option:
```javascript
var redis = new Redis({
// This is the default value of `retryStrategy`
...
quitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
randomkey = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
randomkeyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readonly = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
if (self.options.connectionName) {
debug('set the connection name [%s]', self.options.connectionName);
self.client('setname', self.options.connectionName);
}
if (self.options.readOnly) {
debug('set the connection to readonly mode');
self.readonly().catch(_.noop);
}
if (self.prevCondition) {
var condition = self.prevCondition;
self.prevCondition = null;
if (condition.subscriber && self.options.autoResubscribe) {
// We re-select the previous db first since
...
readonlyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readwrite = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
readwriteBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rename = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renameBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renamenx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
renamenxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
replconf = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
replconfBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
resetCommandQueue = function () { this.commandQueue = new Deque(); }
...
}
EventEmitter.call(this);
Commander.call(this);
this.parseOptions(arguments[0], arguments[1], arguments[2]);
this.resetCommandQueue();
this.resetOfflineQueue();
if (this.options.sentinels) {
this.connector = new SentinelConnector(this.options);
} else {
this.connector = new Connector(this.options);
}
...
resetOfflineQueue = function () { this.offlineQueue = new Deque(); }
...
EventEmitter.call(this);
Commander.call(this);
this.parseOptions(arguments[0], arguments[1], arguments[2]);
this.resetCommandQueue();
this.resetOfflineQueue();
if (this.options.sentinels) {
this.connector = new SentinelConnector(this.options);
} else {
this.connector = new Connector(this.options);
}
...
restore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restore-asking = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restore-askingBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
restoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
returnError = function (err) { var item = this.commandQueue.shift(); err.command = { name: item.command.name, args: item.command.args }; var needReconnect = false; if (this.options.reconnectOnError) { needReconnect = this.options.reconnectOnError(err); } switch (needReconnect) { case 1: case true: if (this.status !== 'reconnecting') { this.disconnect(true); } item.command.reject(err); break; case 2: if (this.status !== 'reconnecting') { this.disconnect(true); } if (this.condition.select !== item.select && item.command.name !== 'select') { this.select(item.select); } this.sendCommand(item.command); break; default: item.command.reject(err); } }
...
var _this = this;
this.replyParser = new Parser({
name: this.options.parser,
stringNumbers: this.options.stringNumbers,
returnBuffers: !this.options.dropBufferSupport,
returnError: function (err) {
_this.returnError(new ReplyError(err.message));
},
returnReply: function (reply) {
_this.returnReply(reply);
},
returnFatalError: function (err) {
_this.flushQueue(err, { offlineQueue: false });
_this.silentEmit('error', new Error('Redis parser fatal error: ' + err.stack));
...
returnReply = function (reply) { if (this.status === 'monitoring') { // Valid commands in the monitoring mode are AUTH and MONITOR, // both of which always reply with 'OK'. var replyStr = reply.toString(); // If not the reply to AUTH & MONITOR if (replyStr !== 'OK') { // Since commands sent in the monitoring mode will trigger an exception, // any replies we received in the monitoring mode should consider to be // realtime monitor data instead of result of commands. var len = replyStr.indexOf(' '); var timestamp = replyStr.slice(0, len); var argindex = replyStr.indexOf('"'); var args = replyStr.slice(argindex + 1, -1).split('" "').map(function (elem) { return elem.replace(/\\"/g, '"'); }); var dbAndSource = replyStr.slice(len + 2, argindex - 2).split(' '); this.emit('monitor', timestamp, args, dbAndSource[1], dbAndSource[0]); return; } } var item, channel, count; if (this.condition.subscriber) { var replyType = Array.isArray(reply) ? reply[0].toString() : null; debug('receive reply "%s" in subscriber mode', replyType); switch (replyType) { case 'message': if (this.listeners('message').length > 0) { this.emit('message', reply[1].toString(), reply[2].toString()); } if (this.listeners('messageBuffer').length > 0) { this.emit('messageBuffer', reply[1], reply[2]); } break; case 'pmessage': var pattern = reply[1].toString(); if (this.listeners('pmessage').length > 0) { this.emit('pmessage', pattern, reply[2].toString(), reply[3].toString()); } if (this.listeners('pmessageBuffer').length > 0) { this.emit('pmessageBuffer', pattern, reply[2], reply[3]); } break; case 'subscribe': case 'psubscribe': channel = reply[1].toString(); this.condition.subscriber.add(replyType, channel); item = this.commandQueue.shift(); if (!fillSubCommand(item.command, reply[2])) { this.commandQueue.unshift(item); } break; case 'unsubscribe': case 'punsubscribe': channel = reply[1] ? reply[1].toString() : null; if (channel) { this.condition.subscriber.del(replyType, channel); } count = reply[2]; if (count === 0) { this.condition.subscriber = false; } item = this.commandQueue.shift(); if (!fillUnsubCommand(item.command, count)) { this.commandQueue.unshift(item); } break; default: item = this.commandQueue.shift(); item.command.resolve(reply); } } else { item = this.commandQueue.shift(); if (!item) { return this.emit('error', new Error('Command queue state error. If you can reproduce this, please report it. Last reply: ' + reply.toString())); } if (Command.checkFlag('ENTER_SUBSCRIBER_MODE', item.command.name)) { this.condition.subscriber = new SubscriptionSet(); this.condition.subscriber.add(item.command.name, reply[1].toString()); if (!fillSubCommand(item.command, reply[2])) { this.commandQueue.unshift(item); } } else if (Command.checkFlag('EXIT_SUBSCRIBER_MODE', item.command.name)) { if (!fillUnsubCommand(item.command, reply[2])) { this.commandQueue.unshift(item); } } else { item.command.resolve(reply); } } function fillSubCommand(command, count) { if (typeof command.remainReplies === 'undefined') { command.remainReplies = command.args.length; } if (--command.remainReplies === 0) { command.resolve(count); return true; } return false; } function fillUnsubCommand(command, count) { if (typeof command.remainReplies === 'undefined') { command.remainReplies = command.args.length; } if (command.remainReplies === 0) { if (count === 0) { command.resolve(reply[2]); return true; } return false; } if (--command.remainReplies === 0) { command.resolve(reply[2]); return t ...
...
name: this.options.parser,
stringNumbers: this.options.stringNumbers,
returnBuffers: !this.options.dropBufferSupport,
returnError: function (err) {
_this.returnError(new ReplyError(err.message));
},
returnReply: function (reply) {
_this.returnReply(reply);
},
returnFatalError: function (err) {
_this.flushQueue(err, { offlineQueue: false });
_this.silentEmit('error', new Error('Redis parser fatal error: ' + err.stack));
_this.disconnect(true);
}
});
...
role = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
roleBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpoplpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpoplpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpush = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
rpushxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
});
// Arguments to commands are flattened, so the following are the same:
redis.sadd('set', 1, 3, 5, 7);
redis.sadd('set', [1, 3, 5, 7]);
// All arguments are passed directly to the redis server:
redis.set('key', 100, 'EX', 10);
```
See the `examples/` folder for more examples.
...
saddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
save = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
saveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scanBufferStream = function (key, options) { if (command === 'scan' || command === 'scanBuffer') { options = key; key = null; } return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
scanStream = function (key, options) { if (command === 'scan' || command === 'scanBuffer') { options = key; key = null; } return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
...
of blocking the server for a long time. However, it requires recording the cursor on the client side each time
the `SCAN` command is called in order to iterate through all the keys correctly. Since it's a relatively common use case, ioredis
provides a streaming interface for the `SCAN` command to make things much easier. A readable stream can be created by calling `scanStream
`:
```javascript
var redis = new Redis();
// Create a readable stream (object mode)
var stream = redis.scanStream();
var keys = [];
stream.on('data', function (resultKeys) {
// `resultKeys` is an array of strings representing key names
for (var i = 0; i < resultKeys.length; i++) {
keys.push(resultKeys[i]);
}
});
...
scard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
scardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
script = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
}
var _this = this;
if (!scripts.length) {
return execPipeline();
}
return this.redis.script('exists', scripts.map(function (item) {
return item.sha;
})).then(function (results) {
var pending = [];
for (var i = 0; i < results.length; ++i) {
if (!results[i]) {
pending.push(scripts[i]);
}
...
scriptBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiff = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sdiffstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
select = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
console.warn('[WARN] Redis server does not require a password, but a password was supplied.');
}
}
});
}
if (self.condition.select) {
self.select(self.condition.select);
}
if (!self.options.enableReadyCheck) {
exports.readyHandler(self)();
}
self.initParser();
...
selectBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sendCommand = function (command, stream) { if (this.status === 'wait') { this.connect().catch(_.noop); } if (this.status === 'end') { command.reject(new Error(utils.CONNECTION_CLOSED_ERROR_MSG)); return command.promise; } if (this.condition.subscriber && !Command.checkFlag('VALID_IN_SUBSCRIBER_MODE', command.name)) { command.reject(new Error('Connection in subscriber mode, only subscriber commands may be used')); return command.promise; } var writable = (this.status === 'ready') || (!stream && (this.status === 'connect') && commands.hasFlag(command.name, 'loading')); if (!this.stream) { writable = false; } else if (!this.stream.writable) { writable = false; } else if (this.stream._writableState && this.stream._writableState.ended) { // https://github.com/iojs/io.js/pull/1217 writable = false; } if (!writable && !this.options.enableOfflineQueue) { command.reject(new Error('Stream isn\'t writeable and enableOfflineQueue options is false')); return command.promise; } if (!writable && command.name === 'quit' && this.offlineQueue.length === 0) { this.disconnect(); command.resolve(new Buffer('OK')); return command.promise; } if (writable) { debug('write command[%d] -> %s(%s)', this.condition.select, command.name, command.args); (stream || this.stream).write(command.toWritable()); this.commandQueue.push({ command: command, stream: stream, select: this.condition.select }); if (Command.checkFlag('WILL_DISCONNECT', command.name)) { this.manuallyClosing = true; } } else if (this.options.enableOfflineQueue) { debug('queue command[%d] -> %s(%s)', this.condition.select, command.name, command.args); this.offlineQueue.push({ command: command, stream: stream, select: this.condition.select }); } if (command.name === 'select' && utils.isInt(command.args[0])) { var db = parseInt(command.args[0], 10); if (this.condition.select !== db) { this.condition.select = db; this.emit('select', db); debug('switch to db [%d]', this.condition.select); } } return command.promise; }
...
if (this.options.showFriendlyErrorStack) {
options.errorStack = new Error().stack;
}
if (this.options.keyPrefix) {
options.keyPrefix = this.options.keyPrefix;
}
return this.sendCommand(new Command(commandName, args, options, callback));
};
}
function generateScriptingFunction(_script, _encoding) {
return function () {
var length = arguments.length;
var lastArgIndex = length - 1;
...
send_command = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sentinel = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
}
});
}
};
SentinelConnector.prototype.updateSentinels = function (client, callback) {
var _this = this;
client.sentinel('sentinels', this.options.name, function (err, result) {
if (err) {
client.disconnect();
return callback(err);
}
if (Array.isArray(result)) {
for (var i = 0; i < result.length; ++i) {
var sentinel = utils.packObject(result[i]);
...
sentinelBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
set = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
## Basic Usage
```javascript
var Redis = require('ioredis');
var redis = new Redis();
redis.set('foo', 'bar');
redis.get('foo', function (err, result) {
console.log(result);
});
// Or using a promise if the last argument isn't a function
redis.get('foo').then(function (result) {
console.log(result);
...
setBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setStatus = function (status, arg) { var address; if (this.options.path) { address = this.options.path; } else if (this.stream && this.stream.remoteAddress && this.stream.remotePort) { address = this.stream.remoteAddress + ':' + this.stream.remotePort; } else { address = this.options.host + ':' + this.options.port; } debug('status[%s]: %s -> %s', address, this.status || '[empty]', status); this.status = status; process.nextTick(this.emit.bind(this, status, arg)); }
...
this.connector = new Connector(this.options);
}
this.retryAttempts = 0;
// end(or wait) -> connecting -> connect -> ready -> end
if (this.options.lazyConnect) {
this.setStatus('wait');
} else {
this.connect().catch(_.noop);
}
}
util.inherits(Redis, EventEmitter);
_.assign(Redis.prototype, Commander.prototype);
...
setbit = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setbitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setnx = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setnxBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
setrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
shutdown = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
shutdownBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
silentEmit = function (eventName) { var error; if (eventName === 'error') { error = arguments[1]; if (this.status === 'end') { return; } if (this.manuallyClosing) { // ignore connection related errors when manually disconnecting if ( error instanceof Error && ( error.message === utils.CONNECTION_CLOSED_ERROR_MSG || error.syscall === 'connect' || error.syscall === 'read' ) ) { return; } } } if (this.listeners(eventName).length > 0) { return this.emit.apply(this, arguments); } if (error && error instanceof Error) { console.error('[ioredis] Unhandled error event:', error.stack); } return false; }
...
subscriber: false
};
var _this = this;
this.connector.connect(function (err, stream) {
if (err) {
_this.flushQueue(err);
_this.silentEmit('error', err);
reject(err);
_this.setStatus('end');
return;
}
var CONNECT_EVENT = _this.options.tls ? 'secureConnect' : 'connect';
_this.stream = stream;
...
sinter = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sinterstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sismember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sismemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slaveof = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slaveofBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slowlog = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
slowlogBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smembers = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smembersBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smove = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
smoveBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sort = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
numberOfKeys: 2,
lua: 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'
});
// Works well with pipelining/transaction
fooRedis.pipeline()
// Sends SORT foo:list BY foo:weight_*->fieldname
.sort('list', 'BY', 'weight_*->fieldname')
// Supports custom commands
// Sends EVALSHA xxx foo:k1 foo:k2 a1 a2
.echo('k1', 'k2', 'a1', 'a2')
.exec()
```
## Transforming Arguments & Replies
...
sortBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
spop = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
spopBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srandmember = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srandmemberBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
srem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sscanBufferStream = function (key, options) { if (command === 'scan' || command === 'scanBuffer') { options = key; key = null; } return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
sscanStream = function (key, options) { if (command === 'scan' || command === 'scanBuffer') { options = key; key = null; } return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
strlen = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
strlenBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
subscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
...
It subscribes to a channel with one connection
and publishes to that channel with the other:
```javascript
var Redis = require('ioredis');
var redis = new Redis();
var pub = new Redis();
redis.subscribe('news', 'music', function (err, count) {
// Now we are subscribed to both the 'news' and 'music' channels.
// `count` represents the number of channels we are currently subscribed to.
pub.publish('news', 'Hello world!');
pub.publish('music', 'Hello again!');
});
...
subscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
substr = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
substrBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunion = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sunionstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
swapdb = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
swapdbBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
sync = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
syncBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
time = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
timeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
touch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
touchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ttl = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
ttlBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
type = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
typeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unlink = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unlinkBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unsubscribe = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unsubscribeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unwatch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
unwatchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
wait = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
waitBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
watch = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
watchBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zadd = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zaddBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcard = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcardBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zincrby = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zincrbyBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zinterstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zinterstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zlexcount = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zlexcountBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrem = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zremrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrange = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangeBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebylex = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebylexBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebyscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrangebyscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrank = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zrevrankBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscan = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscanBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscanBufferStream = function (key, options) { if (command === 'scan' || command === 'scanBuffer') { options = key; key = null; } return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
zscanStream = function (key, options) { if (command === 'scan' || command === 'scanBuffer') { options = key; key = null; } return new ScanStream(_.defaults({ objectMode: true, key: key, redis: this, command: command }, options)); }
n/a
zscore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zscoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zunionstore = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
zunionstoreBuffer = function () { var firstArgIndex = 0; var commandName = _commandName; if (commandName === null) { commandName = arguments[0]; firstArgIndex = 1; } var length = arguments.length; var lastArgIndex = length - 1; var callback = arguments[lastArgIndex]; if (typeof callback !== 'function') { callback = undefined; } else { length = lastArgIndex; } var args = new Array(length - firstArgIndex); for (var i = firstArgIndex; i < length; ++i) { args[i - firstArgIndex] = arguments[i]; } var options; if (this.options.dropBufferSupport) { if (!_encoding) { return Promise.reject(new Error(DROP_BUFFER_SUPPORT_ERROR)).nodeify(callback); } options = { replyEncoding: null }; } else { options = { replyEncoding: _encoding }; } if (this.options.showFriendlyErrorStack) { options.errorStack = new Error().stack; } if (this.options.keyPrefix) { options.keyPrefix = this.options.keyPrefix; } return this.sendCommand(new Command(commandName, args, options, callback)); }
n/a
function ScanStream(opt) { Readable.call(this, opt); this._redisCursor = '0'; this.opt = opt; }
n/a
function Readable(options) { if (!(this instanceof Readable)) return new Readable(options); this._readableState = new ReadableState(options, this); // legacy this.readable = true; if (options && typeof options.read === 'function') this._read = options.read; Stream.call(this); }
n/a
_read = function () { if (this._redisDrained) { this.push(null); return; } var args = [this._redisCursor]; if (this.opt.key) { args.unshift(this.opt.key); } if (this.opt.match) { args.push('MATCH', this.opt.match); } if (this.opt.count) { args.push('COUNT', this.opt.count); } var _this = this; this.opt.redis[this.opt.command](args, function (err, res) { if (err) { _this.emit('error', err); return; } _this._redisCursor = (res[0] instanceof Buffer) ? res[0].toString() : res[0]; if (_this._redisCursor === '0') { _this._redisDrained = true; } _this.push(res[1]); }); }
n/a
close = function () { this._redisDrained = true; }
n/a
function Script(lua, numberOfKeys, keyPrefix) { this.lua = lua; this.sha = crypto.createHash('sha1').update(this.lua).digest('hex'); this.numberOfKeys = typeof numberOfKeys === 'number' ? numberOfKeys : null; this.keyPrefix = keyPrefix ? keyPrefix : ''; }
...
}
var _this = this;
if (!scripts.length) {
return execPipeline();
}
return this.redis.script('exists', scripts.map(function (item) {
return item.sha;
})).then(function (results) {
var pending = [];
for (var i = 0; i < results.length; ++i) {
if (!results[i]) {
pending.push(scripts[i]);
}
...
execute = function (container, args, options, callback) { if (typeof this.numberOfKeys === 'number') { args.unshift(this.numberOfKeys); } if (this.keyPrefix) { options.keyPrefix = this.keyPrefix; } var evalsha = new Command('evalsha', [this.sha].concat(args), options); evalsha.isCustomCommand = true; var result = container.sendCommand(evalsha); if (result instanceof Promise) { var _this = this; return result.catch(function (err) { if (err.toString().indexOf('NOSCRIPT') === -1) { throw err; } return container.sendCommand(new Command('eval', [_this.lua].concat(args), options)); }).nodeify(callback); } // result is not a Promise--probably returned from a pipeline chain; however, // we still need the callback to fire when the script is evaluated evalsha.promise.nodeify(callback); return result; }
...
options = { replyEncoding: _encoding };
}
if (this.options.showFriendlyErrorStack) {
options.errorStack = new Error().stack;
}
return _script.execute(this, args, options, callback);
};
}
module.exports = Commander;
...
function SentinelConnector(options) { Connector.call(this, options); if (this.options.sentinels.length === 0) { throw new Error('Requires at least one sentinel to connect to.'); } if (!this.options.name) { throw new Error('Requires the name of master.'); } }
n/a
function Connector(options) { this.options = options; }
n/a
check = function (info) { if (info.role && this.options.role !== info.role) { debug('role invalid, expected %s, but got %s', this.options.role, info.role); return false; } return true; }
...
if (!flushed) {
self.flushQueue(new Error('Ready check failed: ' + err.message));
self.silentEmit('error', err);
self.disconnect(true);
}
} else {
self.serverInfo = info;
if (self.connector.check(info)) {
exports.readyHandler(self)();
} else {
self.disconnect(true);
}
}
});
}
...
connect = function (callback) { this.connecting = true; this.retryAttempts = 0; if (typeof this.currentPoint !== 'number') { this.currentPoint = -1; } if (!Array.isArray(this.sentinels)) { this.sentinels = this.options.sentinels; } var _this = this; var lastError; connectToNext(); function connectToNext() { _this.currentPoint += 1; if (_this.currentPoint === _this.sentinels.length) { _this.currentPoint = -1; var retryDelay; if (typeof _this.options.sentinelRetryStrategy === 'function') { retryDelay = _this.options.sentinelRetryStrategy(++_this.retryAttempts); } if (typeof retryDelay !== 'number') { debug('All sentinels are unreachable and retry is disabled, emitting error...'); var error = 'All sentinels are unreachable.'; if (lastError) { error += ' Last error: ' + lastError.message; } return callback(new Error(error)); } debug('All sentinels are unreachable. Retrying from scratch after %d', retryDelay); setTimeout(connectToNext, retryDelay); return; } var endpoint = _this.sentinels[_this.currentPoint]; _this.resolve(endpoint, function (err, resolved) { if (!_this.connecting) { callback(new Error(utils.CONNECTION_CLOSED_ERROR_MSG)); return; } if (resolved) { _this.stream = net.createConnection(resolved); callback(null, _this.stream); } else if (err) { debug('failed to connect to sentinel %s:%s because %s', endpoint.host, endpoint.port, err); lastError = err; connectToNext(); } else { debug('connected to sentinel %s:%s successfully, but got a invalid reply: %s', endpoint.host, endpoint.port, resolved); connectToNext(); } }); } }
...
});
```
`retryStrategy` is a function that will be called when the connection is lost.
The argument `times` means this is the nth reconnection being made and
the return value represents how long (in ms) to wait to reconnect. When the
return value isn't a number, ioredis will stop trying to reconnect, and the connection
will be lost forever if the user doesn't call `redis.connect()` manually.
When reconnected, the client will auto subscribe to channels that the previous connection subscribed to.
This behavior can be disabled by setting the `autoResubscribe` option to `false`.
And if the previous connection has some unfulfilled commands (most likely blocking commands such as `brpop` and `blpop`),
the client will resend them when reconnected. This behavior can be disabled by setting the `autoResendUnfulfilledCommands` option
to `false`.
...
resolve = function (endpoint, callback) { if (typeof Redis === 'undefined') { Redis = require('../redis'); } var client = new Redis({ port: endpoint.port, host: endpoint.host, retryStrategy: null, enableReadyCheck: false, connectTimeout: this.options.connectTimeout, dropBufferSupport: true }); // ignore the errors since resolve* methods will handle them client.on('error', noop); if (this.options.role === 'slave') { this.resolveSlave(client, callback); } else { this.resolveMaster(client, callback); } }
...
var ignoredCount = 0;
for (i = 0; i < this._queue.length - ignoredCount; ++i) {
if (this._queue[i + ignoredCount].ignore) {
ignoredCount += 1;
}
this._result[i] = this._result[i + ignoredCount];
}
this.resolve(this._result.slice(0, this._result.length - ignoredCount));
};
Pipeline.prototype.sendCommand = function (command) {
var position = this._queue.length;
var _this = this;
...
resolveMaster = function (client, callback) { var _this = this; client.sentinel('get-master-addr-by-name', this.options.name, function (err, result) { if (err) { client.disconnect(); return callback(err); } _this.updateSentinels(client, function (err) { client.disconnect(); if (err) { return callback(err); } callback(null, Array.isArray(result) ? { host: result[0], port: result[1] } : null); }); }); }
...
// ignore the errors since resolve* methods will handle them
client.on('error', noop);
if (this.options.role === 'slave') {
this.resolveSlave(client, callback);
} else {
this.resolveMaster(client, callback);
}
};
function noop() {}
function isSentinelEql(a, b) {
return ((a.host || '127.0.0.1') === (b.host || '127.0.0.1')) &&
...
resolveSlave = function (client, callback) { var _this = this; client.sentinel('slaves', this.options.name, function (err, result) { client.disconnect(); if (err) { return callback(err); } var selectedSlave; if (Array.isArray(result)) { var availableSlaves = []; for (var i = 0; i < result.length; ++i) { var slave = utils.packObject(result[i]); if (slave.flags && !slave.flags.match(/(disconnected|s_down|o_down)/)) { availableSlaves.push(slave); } } // allow the options to prefer particular slave(s) if (_this.options.preferredSlaves) { var preferredSlaves = _this.options.preferredSlaves; switch (typeof preferredSlaves) { case 'function': // use function from options to filter preferred slave selectedSlave = _this.options.preferredSlaves(availableSlaves); break; case 'object': if (!Array.isArray(preferredSlaves)) { preferredSlaves = [preferredSlaves]; } else { // sort by priority preferredSlaves.sort(function (a, b) { // default the priority to 1 if (!a.prio) { a.prio = 1; } if (!b.prio) { b.prio = 1; } // lowest priority first if (a.prio < b.prio) { return -1; } if (a.prio > b.prio) { return 1; } return 0; }); } // loop over preferred slaves and return the first match for (var p = 0; p < preferredSlaves.length; p++) { for (var a = 0; a < availableSlaves.length; a++) { if (availableSlaves[a].ip === preferredSlaves[p].ip) { if (availableSlaves[a].port === preferredSlaves[p].port) { selectedSlave = availableSlaves[a]; break; } } } if (selectedSlave) { break; } } // if none of the preferred slaves are available, a random available slave is returned break; } } if (!selectedSlave) { // get a random available slave selectedSlave = _.sample(availableSlaves); } } callback(null, selectedSlave ? { host: selectedSlave.ip, port: selectedSlave.port } : null); }); }
...
dropBufferSupport: true
});
// ignore the errors since resolve* methods will handle them
client.on('error', noop);
if (this.options.role === 'slave') {
this.resolveSlave(client, callback);
} else {
this.resolveMaster(client, callback);
}
};
function noop() {}
...
updateSentinels = function (client, callback) { var _this = this; client.sentinel('sentinels', this.options.name, function (err, result) { if (err) { client.disconnect(); return callback(err); } if (Array.isArray(result)) { for (var i = 0; i < result.length; ++i) { var sentinel = utils.packObject(result[i]); var flags = sentinel.flags ? sentinel.flags.split(',') : []; if (flags.indexOf('disconnected') === -1 && sentinel.ip && sentinel.port) { var endpoint = { host: sentinel.ip, port: parseInt(sentinel.port, 10) }; var isDuplicate = _this.sentinels.some(_.bind(isSentinelEql, null, endpoint)); if (!isDuplicate) { debug('adding sentinel %s:%s', endpoint.host, endpoint.port); _this.sentinels.push(endpoint); } } } debug('sentinels', _this.sentinels); } callback(null); }); }
...
SentinelConnector.prototype.resolveMaster = function (client, callback) {
var _this = this;
client.sentinel('get-master-addr-by-name', this.options.name, function (err, result) {
if (err) {
client.disconnect();
return callback(err);
}
_this.updateSentinels(client, function (err) {
client.disconnect();
if (err) {
return callback(err);
}
callback(null, Array.isArray(result) ? { host: result[0], port: result[1] } : null);
});
});
...
function SubscriptionSet() { this.set = { subscribe: {}, psubscribe: {} }; }
n/a
add = function (set, channel) { this.set[mapSet(set)][channel] = true; }
...
if (this.listeners('pmessageBuffer').length > 0) {
this.emit('pmessageBuffer', pattern, reply[2], reply[3]);
}
break;
case 'subscribe':
case 'psubscribe':
channel = reply[1].toString();
this.condition.subscriber.add(replyType, channel);
item = this.commandQueue.shift();
if (!fillSubCommand(item.command, reply[2])) {
this.commandQueue.unshift(item);
}
break;
case 'unsubscribe':
case 'punsubscribe':
...
channels = function (set) { return Object.keys(this.set[mapSet(set)]); }
...
};
SubscriptionSet.prototype.channels = function (set) {
return Object.keys(this.set[mapSet(set)]);
};
SubscriptionSet.prototype.isEmpty = function () {
return this.channels('subscribe').length === 0 && this.channels(
x27;psubscribe').length === 0;
};
function mapSet(set) {
if (set === 'unsubscribe') {
return 'subscribe';
}
if (set === 'punsubscribe') {
...
del = function (set, channel) { delete this.set[mapSet(set)][channel]; }
...
`redis.pipeline()` creates a `Pipeline` instance. You can call any Redis
commands on it just like the `Redis` instance. The commands are queued in memory
and flushed to Redis by calling the `exec` method:
```javascript
var pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('cc');
pipeline.exec(function (err, results) {
// `err` is always null, and `results` is an array of responses
// corresponding to the sequence of queued commands.
// Each response follows the format `[err, result]`.
});
// You can even chain the commands:
...
isEmpty = function () { return this.channels('subscribe').length === 0 && this.channels('psubscribe').length === 0; }
...
this._transactions -= 1;
return (this.options.dropBufferSupport ? exec : execBuffer).apply(this, arguments);
}
if (!this.nodeifiedPromise) {
this.nodeifiedPromise = true;
this.promise.nodeify(callback);
}
if (_.isEmpty(this._queue)) {
this.resolve([]);
}
var pipelineSlot, i;
if (this.isCluster) {
// List of the first key for each command
var sampleKeys = [];
for (i = 0; i < this._queue.length; i++) {
...
addTransactionSupport = function (redis) { redis.pipeline = function (commands) { var pipeline = new Pipeline(this); if (Array.isArray(commands)) { pipeline.addBatch(commands); } return pipeline; }; var multi = redis.multi; redis.multi = function (commands, options) { if (typeof options === 'undefined' && !Array.isArray(commands)) { options = commands; commands = null; } if (options && options.pipeline === false) { return multi.call(this); } var pipeline = new Pipeline(this); pipeline.multi(); if (Array.isArray(commands)) { pipeline.addBatch(commands); } var exec = pipeline.exec; pipeline.exec = function (callback) { if (this._transactions > 0) { exec.call(pipeline); } var promise = exec.call(pipeline); return promise.then(function (result) { var execResult = result[result.length - 1]; if (execResult[0]) { execResult[0].previousErrors = []; for (var i = 0; i < result.length - 1; ++i) { if (result[i][0]) { execResult[0].previousErrors.push(result[i][0]); } } throw execResult[0]; } return utils.wrapMultiResult(execResult[1]); }).nodeify(callback); }; var execBuffer = pipeline.execBuffer; pipeline.execBuffer = function (callback) { if (this._transactions > 0) { execBuffer.call(pipeline); } return pipeline.exec(callback); }; return pipeline; }; var exec = redis.exec; redis.exec = function (callback) { return exec.call(this).then(function (results) { if (Array.isArray(results)) { results = utils.wrapMultiResult(results); } return results; }).nodeify(callback); }; }
...
return new Promise(function (resolve) {
monitorInstance.once('monitoring', function () {
resolve(monitorInstance);
});
}).nodeify(callback);
};
require('./transaction').addTransactionSupport(Redis.prototype);
/**
* Send a command to Redis
*
* This method is used internally by the `Redis#set`, `Redis#lpush` etc.
* Most of the time you won't invoke this method directly.
* However when you want to send a command that is not supported by ioredis yet,
...