redis 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/heroku/index.js +14 -0
- package/heroku/node_modules/.package-lock.json +57 -0
- package/heroku/node_modules/denque/CHANGELOG.md +4 -0
- package/heroku/node_modules/denque/LICENSE +13 -0
- package/heroku/node_modules/denque/README.md +362 -0
- package/heroku/node_modules/denque/index.d.ts +31 -0
- package/heroku/node_modules/denque/index.js +443 -0
- package/heroku/node_modules/denque/package.json +55 -0
- package/heroku/node_modules/redis/.deepsource.toml +9 -0
- package/heroku/node_modules/redis/CHANGELOG.md +880 -0
- package/heroku/node_modules/redis/LICENSE +24 -0
- package/heroku/node_modules/redis/README.md +1009 -0
- package/{a.js → heroku/node_modules/redis/a.js} +0 -0
- package/heroku/node_modules/redis/index.js +1039 -0
- package/heroku/node_modules/redis/lib/command.js +16 -0
- package/heroku/node_modules/redis/lib/commands.js +105 -0
- package/heroku/node_modules/redis/lib/createClient.js +88 -0
- package/heroku/node_modules/redis/lib/customErrors.js +58 -0
- package/heroku/node_modules/redis/lib/debug.js +13 -0
- package/heroku/node_modules/redis/lib/extendedApi.js +113 -0
- package/heroku/node_modules/redis/lib/individualCommands.js +629 -0
- package/heroku/node_modules/redis/lib/multi.js +187 -0
- package/heroku/node_modules/redis/lib/utils.js +134 -0
- package/{npm → heroku/node_modules/redis/npm} +0 -0
- package/heroku/node_modules/redis/package.json +77 -0
- package/heroku/node_modules/redis-commands/LICENSE +22 -0
- package/heroku/node_modules/redis-commands/README.md +51 -0
- package/heroku/node_modules/redis-commands/changelog.md +83 -0
- package/heroku/node_modules/redis-commands/commands.json +2334 -0
- package/heroku/node_modules/redis-commands/index.js +168 -0
- package/heroku/node_modules/redis-commands/package.json +41 -0
- package/heroku/node_modules/redis-commands/tools/build.js +62 -0
- package/heroku/node_modules/redis-errors/LICENSE +22 -0
- package/heroku/node_modules/redis-errors/README.md +116 -0
- package/heroku/node_modules/redis-errors/index.js +7 -0
- package/heroku/node_modules/redis-errors/lib/modern.js +59 -0
- package/heroku/node_modules/redis-errors/lib/old.js +119 -0
- package/heroku/node_modules/redis-errors/package.json +41 -0
- package/heroku/node_modules/redis-parser/LICENSE +22 -0
- package/heroku/node_modules/redis-parser/README.md +166 -0
- package/heroku/node_modules/redis-parser/changelog.md +156 -0
- package/heroku/node_modules/redis-parser/index.js +3 -0
- package/heroku/node_modules/redis-parser/lib/parser.js +552 -0
- package/heroku/node_modules/redis-parser/package.json +53 -0
- package/heroku/package.json +9 -0
- package/lib/utils.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var betterStackTraces = /development/i.test(process.env.NODE_ENV) || /\bredis\b/i.test(process.env.NODE_DEBUG);
|
|
4
|
+
|
|
5
|
+
function Command (command, args, callback, call_on_write) {
|
|
6
|
+
this.command = command;
|
|
7
|
+
this.args = args;
|
|
8
|
+
this.buffer_args = false;
|
|
9
|
+
this.callback = callback;
|
|
10
|
+
this.call_on_write = call_on_write;
|
|
11
|
+
if (betterStackTraces) {
|
|
12
|
+
this.error = new Error();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = Command;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commands = require('redis-commands');
|
|
4
|
+
var Multi = require('./multi');
|
|
5
|
+
var RedisClient = require('../').RedisClient;
|
|
6
|
+
var Command = require('./command');
|
|
7
|
+
|
|
8
|
+
var addCommand = function (command) {
|
|
9
|
+
// Some rare Redis commands use special characters in their command name
|
|
10
|
+
// Convert those to a underscore to prevent using invalid function names
|
|
11
|
+
var commandName = command.replace(/(?:^([0-9])|[^a-zA-Z0-9_$])/g, '_$1');
|
|
12
|
+
|
|
13
|
+
// Do not override existing functions
|
|
14
|
+
if (!RedisClient.prototype[command]) {
|
|
15
|
+
RedisClient.prototype[command.toUpperCase()] = RedisClient.prototype[command] = function () {
|
|
16
|
+
var arr;
|
|
17
|
+
var len = arguments.length;
|
|
18
|
+
var callback;
|
|
19
|
+
var i = 0;
|
|
20
|
+
if (Array.isArray(arguments[0])) {
|
|
21
|
+
arr = arguments[0];
|
|
22
|
+
if (len === 2) {
|
|
23
|
+
callback = arguments[1];
|
|
24
|
+
}
|
|
25
|
+
} else if (len > 1 && Array.isArray(arguments[1])) {
|
|
26
|
+
if (len === 3) {
|
|
27
|
+
callback = arguments[2];
|
|
28
|
+
}
|
|
29
|
+
len = arguments[1].length;
|
|
30
|
+
arr = new Array(len + 1);
|
|
31
|
+
arr[0] = arguments[0];
|
|
32
|
+
for (; i < len; i += 1) {
|
|
33
|
+
arr[i + 1] = arguments[1][i];
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
// The later should not be the average use case
|
|
37
|
+
if (len !== 0 && (typeof arguments[len - 1] === 'function' || typeof arguments[len - 1] === 'undefined')) {
|
|
38
|
+
len--;
|
|
39
|
+
callback = arguments[len];
|
|
40
|
+
}
|
|
41
|
+
arr = new Array(len);
|
|
42
|
+
for (; i < len; i += 1) {
|
|
43
|
+
arr[i] = arguments[i];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return this.internal_send_command(new Command(command, arr, callback));
|
|
47
|
+
};
|
|
48
|
+
// Alias special function names (e.g. NR.RUN becomes NR_RUN and nr_run)
|
|
49
|
+
if (commandName !== command) {
|
|
50
|
+
RedisClient.prototype[commandName.toUpperCase()] = RedisClient.prototype[commandName] = RedisClient.prototype[command];
|
|
51
|
+
}
|
|
52
|
+
Object.defineProperty(RedisClient.prototype[command], 'name', {
|
|
53
|
+
value: commandName
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Do not override existing functions
|
|
58
|
+
if (!Multi.prototype[command]) {
|
|
59
|
+
Multi.prototype[command.toUpperCase()] = Multi.prototype[command] = function () {
|
|
60
|
+
var arr;
|
|
61
|
+
var len = arguments.length;
|
|
62
|
+
var callback;
|
|
63
|
+
var i = 0;
|
|
64
|
+
if (Array.isArray(arguments[0])) {
|
|
65
|
+
arr = arguments[0];
|
|
66
|
+
if (len === 2) {
|
|
67
|
+
callback = arguments[1];
|
|
68
|
+
}
|
|
69
|
+
} else if (len > 1 && Array.isArray(arguments[1])) {
|
|
70
|
+
if (len === 3) {
|
|
71
|
+
callback = arguments[2];
|
|
72
|
+
}
|
|
73
|
+
len = arguments[1].length;
|
|
74
|
+
arr = new Array(len + 1);
|
|
75
|
+
arr[0] = arguments[0];
|
|
76
|
+
for (; i < len; i += 1) {
|
|
77
|
+
arr[i + 1] = arguments[1][i];
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
// The later should not be the average use case
|
|
81
|
+
if (len !== 0 && (typeof arguments[len - 1] === 'function' || typeof arguments[len - 1] === 'undefined')) {
|
|
82
|
+
len--;
|
|
83
|
+
callback = arguments[len];
|
|
84
|
+
}
|
|
85
|
+
arr = new Array(len);
|
|
86
|
+
for (; i < len; i += 1) {
|
|
87
|
+
arr[i] = arguments[i];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
this.queue.push(new Command(command, arr, callback));
|
|
91
|
+
return this;
|
|
92
|
+
};
|
|
93
|
+
// Alias special function names (e.g. NR.RUN becomes NR_RUN and nr_run)
|
|
94
|
+
if (commandName !== command) {
|
|
95
|
+
Multi.prototype[commandName.toUpperCase()] = Multi.prototype[commandName] = Multi.prototype[command];
|
|
96
|
+
}
|
|
97
|
+
Object.defineProperty(Multi.prototype[command], 'name', {
|
|
98
|
+
value: commandName
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
commands.list.forEach(addCommand);
|
|
104
|
+
|
|
105
|
+
module.exports = addCommand;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('./utils');
|
|
4
|
+
var URL = require('url');
|
|
5
|
+
|
|
6
|
+
module.exports = function createClient (port_arg, host_arg, options) {
|
|
7
|
+
|
|
8
|
+
if (typeof port_arg === 'number' || typeof port_arg === 'string' && /^\d+$/.test(port_arg)) {
|
|
9
|
+
|
|
10
|
+
var host;
|
|
11
|
+
if (typeof host_arg === 'string') {
|
|
12
|
+
host = host_arg;
|
|
13
|
+
} else {
|
|
14
|
+
if (options && host_arg) {
|
|
15
|
+
throw new TypeError('Unknown type of connection in createClient()');
|
|
16
|
+
}
|
|
17
|
+
options = options || host_arg;
|
|
18
|
+
}
|
|
19
|
+
options = utils.clone(options);
|
|
20
|
+
options.host = host || options.host;
|
|
21
|
+
options.port = port_arg;
|
|
22
|
+
|
|
23
|
+
} else if (typeof port_arg === 'string' || port_arg && port_arg.url) {
|
|
24
|
+
|
|
25
|
+
options = utils.clone(port_arg.url ? port_arg : host_arg || options);
|
|
26
|
+
var url = port_arg.url || port_arg;
|
|
27
|
+
var parsed = URL.parse(url, true, true);
|
|
28
|
+
|
|
29
|
+
// [redis:]//[[user][:password]@][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]
|
|
30
|
+
if (parsed.slashes) { // We require slashes
|
|
31
|
+
if (parsed.auth) {
|
|
32
|
+
var columnIndex = parsed.auth.indexOf(':');
|
|
33
|
+
options.password = parsed.auth.slice(columnIndex + 1);
|
|
34
|
+
if (columnIndex > 0) {
|
|
35
|
+
options.user = parsed.auth.slice(0, columnIndex);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (parsed.protocol) {
|
|
39
|
+
if (parsed.protocol === 'rediss:') {
|
|
40
|
+
options.tls = options.tls || {};
|
|
41
|
+
} else if (parsed.protocol !== 'redis:') {
|
|
42
|
+
console.warn('node_redis: WARNING: You passed "' + parsed.protocol.substring(0, parsed.protocol.length - 1) + '" as protocol instead of the "redis" protocol!');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (parsed.pathname && parsed.pathname !== '/') {
|
|
46
|
+
options.db = parsed.pathname.substr(1);
|
|
47
|
+
}
|
|
48
|
+
if (parsed.hostname) {
|
|
49
|
+
options.host = parsed.hostname;
|
|
50
|
+
}
|
|
51
|
+
if (parsed.port) {
|
|
52
|
+
options.port = parsed.port;
|
|
53
|
+
}
|
|
54
|
+
if (parsed.search !== '') {
|
|
55
|
+
var elem;
|
|
56
|
+
for (elem in parsed.query) {
|
|
57
|
+
// If options are passed twice, only the parsed options will be used
|
|
58
|
+
if (elem in options) {
|
|
59
|
+
if (options[elem] === parsed.query[elem]) {
|
|
60
|
+
console.warn('node_redis: WARNING: You passed the ' + elem + ' option twice!');
|
|
61
|
+
} else {
|
|
62
|
+
throw new RangeError('The ' + elem + ' option is added twice and does not match');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
options[elem] = parsed.query[elem];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
} else if (parsed.hostname) {
|
|
69
|
+
throw new RangeError('The redis url must begin with slashes "//" or contain slashes after the redis protocol');
|
|
70
|
+
} else {
|
|
71
|
+
options.path = url;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
} else if (typeof port_arg === 'object' || port_arg === undefined) {
|
|
75
|
+
options = utils.clone(port_arg || options);
|
|
76
|
+
options.host = options.host || host_arg;
|
|
77
|
+
|
|
78
|
+
if (port_arg && arguments.length !== 1) {
|
|
79
|
+
throw new TypeError('Too many arguments passed to createClient. Please only pass the options object');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!options) {
|
|
84
|
+
throw new TypeError('Unknown type of connection in createClient()');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return options;
|
|
88
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var util = require('util');
|
|
4
|
+
var assert = require('assert');
|
|
5
|
+
var RedisError = require('redis-errors').RedisError;
|
|
6
|
+
var ADD_STACKTRACE = false;
|
|
7
|
+
|
|
8
|
+
function AbortError (obj, stack) {
|
|
9
|
+
assert(obj, 'The options argument is required');
|
|
10
|
+
assert.strictEqual(typeof obj, 'object', 'The options argument has to be of type object');
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(this, 'message', {
|
|
13
|
+
value: obj.message || '',
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true
|
|
16
|
+
});
|
|
17
|
+
if (stack || stack === undefined) {
|
|
18
|
+
Error.captureStackTrace(this, AbortError);
|
|
19
|
+
}
|
|
20
|
+
for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
|
|
21
|
+
this[key] = obj[key];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function AggregateError (obj) {
|
|
26
|
+
assert(obj, 'The options argument is required');
|
|
27
|
+
assert.strictEqual(typeof obj, 'object', 'The options argument has to be of type object');
|
|
28
|
+
|
|
29
|
+
AbortError.call(this, obj, ADD_STACKTRACE);
|
|
30
|
+
Object.defineProperty(this, 'message', {
|
|
31
|
+
value: obj.message || '',
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true
|
|
34
|
+
});
|
|
35
|
+
Error.captureStackTrace(this, AggregateError);
|
|
36
|
+
for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
|
|
37
|
+
this[key] = obj[key];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
util.inherits(AbortError, RedisError);
|
|
42
|
+
util.inherits(AggregateError, AbortError);
|
|
43
|
+
|
|
44
|
+
Object.defineProperty(AbortError.prototype, 'name', {
|
|
45
|
+
value: 'AbortError',
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(AggregateError.prototype, 'name', {
|
|
50
|
+
value: 'AggregateError',
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
AbortError: AbortError,
|
|
57
|
+
AggregateError: AggregateError
|
|
58
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('../');
|
|
4
|
+
|
|
5
|
+
function debug () {
|
|
6
|
+
if (index.debug_mode) {
|
|
7
|
+
var data = Array.prototype.slice.call(arguments);
|
|
8
|
+
data.unshift(new Date().toISOString());
|
|
9
|
+
console.error.apply(null, data);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = debug;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('./utils');
|
|
4
|
+
var debug = require('./debug');
|
|
5
|
+
var RedisClient = require('../').RedisClient;
|
|
6
|
+
var Command = require('./command');
|
|
7
|
+
var noop = function () {};
|
|
8
|
+
|
|
9
|
+
/**********************************************
|
|
10
|
+
All documented and exposed API belongs in here
|
|
11
|
+
**********************************************/
|
|
12
|
+
|
|
13
|
+
// Redirect calls to the appropriate function and use to send arbitrary / not supported commands
|
|
14
|
+
RedisClient.prototype.send_command = RedisClient.prototype.sendCommand = function (command, args, callback) {
|
|
15
|
+
// Throw to fail early instead of relying in order in this case
|
|
16
|
+
if (typeof command !== 'string') {
|
|
17
|
+
throw new TypeError('Wrong input type "' + (command !== null && command !== undefined ? command.constructor.name : command) + '" for command name');
|
|
18
|
+
}
|
|
19
|
+
command = command.toLowerCase();
|
|
20
|
+
if (!Array.isArray(args)) {
|
|
21
|
+
if (args === undefined || args === null) {
|
|
22
|
+
args = [];
|
|
23
|
+
} else if (typeof args === 'function' && callback === undefined) {
|
|
24
|
+
callback = args;
|
|
25
|
+
args = [];
|
|
26
|
+
} else {
|
|
27
|
+
throw new TypeError('Wrong input type "' + args.constructor.name + '" for args');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (typeof callback !== 'function' && callback !== undefined) {
|
|
31
|
+
throw new TypeError('Wrong input type "' + (callback !== null ? callback.constructor.name : 'null') + '" for callback function');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Using the raw multi command is only possible with this function
|
|
35
|
+
// If the command is not yet added to the client, the internal function should be called right away
|
|
36
|
+
// Otherwise we need to redirect the calls to make sure the internal functions don't get skipped
|
|
37
|
+
// The internal functions could actually be used for any non hooked function
|
|
38
|
+
// but this might change from time to time and at the moment there's no good way to distinguish them
|
|
39
|
+
// from each other, so let's just do it do it this way for the time being
|
|
40
|
+
if (command === 'multi' || typeof this[command] !== 'function') {
|
|
41
|
+
return this.internal_send_command(new Command(command, args, callback));
|
|
42
|
+
}
|
|
43
|
+
if (typeof callback === 'function') {
|
|
44
|
+
args = args.concat([callback]); // Prevent manipulating the input array
|
|
45
|
+
}
|
|
46
|
+
return this[command].apply(this, args);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
RedisClient.prototype.end = function (flush) {
|
|
50
|
+
// Flush queue if wanted
|
|
51
|
+
if (flush) {
|
|
52
|
+
this.flush_and_error({
|
|
53
|
+
message: 'Connection forcefully ended and command aborted.',
|
|
54
|
+
code: 'NR_CLOSED'
|
|
55
|
+
});
|
|
56
|
+
} else if (arguments.length === 0) {
|
|
57
|
+
this.warn(
|
|
58
|
+
'Using .end() without the flush parameter is deprecated and throws from v.3.0.0 on.\n' +
|
|
59
|
+
'Please check the doku (https://github.com/NodeRedis/node_redis) and explictly use flush.'
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
// Clear retry_timer
|
|
63
|
+
if (this.retry_timer) {
|
|
64
|
+
clearTimeout(this.retry_timer);
|
|
65
|
+
this.retry_timer = null;
|
|
66
|
+
}
|
|
67
|
+
this.stream.removeAllListeners();
|
|
68
|
+
this.stream.on('error', noop);
|
|
69
|
+
this.connected = false;
|
|
70
|
+
this.ready = false;
|
|
71
|
+
this.closing = true;
|
|
72
|
+
return this.stream.destroySoon();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
RedisClient.prototype.unref = function () {
|
|
76
|
+
if (this.connected) {
|
|
77
|
+
debug("Unref'ing the socket connection");
|
|
78
|
+
this.stream.unref();
|
|
79
|
+
} else {
|
|
80
|
+
debug('Not connected yet, will unref later');
|
|
81
|
+
this.once('connect', function () {
|
|
82
|
+
this.unref();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
RedisClient.prototype.duplicate = function (options, callback) {
|
|
88
|
+
if (typeof options === 'function') {
|
|
89
|
+
callback = options;
|
|
90
|
+
options = null;
|
|
91
|
+
}
|
|
92
|
+
var existing_options = utils.clone(this.options);
|
|
93
|
+
options = utils.clone(options);
|
|
94
|
+
for (var elem in options) {
|
|
95
|
+
existing_options[elem] = options[elem];
|
|
96
|
+
}
|
|
97
|
+
var client = new RedisClient(existing_options);
|
|
98
|
+
client.selected_db = options.db || this.selected_db;
|
|
99
|
+
if (typeof callback === 'function') {
|
|
100
|
+
var ready_listener = function () {
|
|
101
|
+
callback(null, client);
|
|
102
|
+
client.removeAllListeners(error_listener);
|
|
103
|
+
};
|
|
104
|
+
var error_listener = function (err) {
|
|
105
|
+
callback(err);
|
|
106
|
+
client.end(true);
|
|
107
|
+
};
|
|
108
|
+
client.once('ready', ready_listener);
|
|
109
|
+
client.once('error', error_listener);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
return client;
|
|
113
|
+
};
|