Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ioredis

Package Overview
Dependencies
Maintainers
2
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ioredis - npm Package Compare versions

Comparing version 4.24.2 to 4.24.3

1

built/autoPipelining.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeWithAutoPipelining = exports.shouldUseAutoPipelining = exports.notAllowedAutoPipelineCommands = exports.kCallbacks = exports.kExec = void 0;
const PromiseContainer = require("./promiseContainer");

@@ -4,0 +5,0 @@ const calculateSlot = require("cluster-key-slot");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_CLUSTER_OPTIONS = void 0;
const dns_1 = require("dns");

@@ -4,0 +5,0 @@ exports.DEFAULT_CLUSTER_OPTIONS = {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.weightSrvRecords = exports.groupSrvRecords = exports.getUniqueHostnamesFromOptions = exports.normalizeNodeOptions = exports.nodeKeyToRedisOptions = exports.getNodeKey = void 0;
const utils_1 = require("../utils");

@@ -4,0 +5,0 @@ const net_1 = require("net");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SentinelConnector = exports.StandaloneConnector = void 0;
const StandaloneConnector_1 = require("./StandaloneConnector");

@@ -4,0 +5,0 @@ exports.StandaloneConnector = StandaloneConnector_1.default;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SentinelIterator = void 0;
const net_1 = require("net");

@@ -4,0 +5,0 @@ const utils_1 = require("../../utils");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isIIpcConnectionOptions = void 0;
const net_1 = require("net");

@@ -4,0 +5,0 @@ const tls_1 = require("tls");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MaxRetriesPerRequestError = void 0;
const MaxRetriesPerRequestError_1 = require("./MaxRetriesPerRequestError");
exports.MaxRetriesPerRequestError = MaxRetriesPerRequestError_1.default;

17

built/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.print = exports.ReplyError = void 0;
exports = module.exports = require("./redis").default;
var redis_1 = require("./redis");
exports.default = redis_1.default;
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return redis_1.default; } });
var cluster_1 = require("./cluster");
exports.Cluster = cluster_1.default;
Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return cluster_1.default; } });
var command_1 = require("./command");
exports.Command = command_1.default;
Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return command_1.default; } });
var ScanStream_1 = require("./ScanStream");
exports.ScanStream = ScanStream_1.default;
Object.defineProperty(exports, "ScanStream", { enumerable: true, get: function () { return ScanStream_1.default; } });
var pipeline_1 = require("./pipeline");
exports.Pipeline = pipeline_1.default;
Object.defineProperty(exports, "Pipeline", { enumerable: true, get: function () { return pipeline_1.default; } });
var AbstractConnector_1 = require("./connectors/AbstractConnector");
exports.AbstractConnector = AbstractConnector_1.default;
Object.defineProperty(exports, "AbstractConnector", { enumerable: true, get: function () { return AbstractConnector_1.default; } });
var SentinelConnector_1 = require("./connectors/SentinelConnector");
exports.SentinelConnector = SentinelConnector_1.default;
exports.SentinelIterator = SentinelConnector_1.SentinelIterator;
Object.defineProperty(exports, "SentinelConnector", { enumerable: true, get: function () { return SentinelConnector_1.default; } });
Object.defineProperty(exports, "SentinelIterator", { enumerable: true, get: function () { return SentinelConnector_1.SentinelIterator; } });
// No TS typings

@@ -20,0 +21,0 @@ exports.ReplyError = require("redis-errors").ReplyError;

@@ -268,7 +268,8 @@ "use strict";

const script = this._shaToScript[item.args[0]];
if (!script || this.redis._addedScriptHashes[script.sha]) {
if (!script ||
this.redis._addedScriptHashes[script.sha] ||
scripts.includes(script)) {
continue;
}
scripts.push(script);
this.redis._addedScriptHashes[script.sha] = true;
}

@@ -283,3 +284,8 @@ const _this = this;

concurrency: 10,
}).then(execPipeline);
}).then(function () {
for (let i = 0; i < scripts.length; i++) {
_this.redis._addedScriptHashes[scripts[i].sha] = true;
}
return execPipeline();
});
}

@@ -300,3 +306,8 @@ return this.redis

})
.then(execPipeline);
.then(function () {
for (let i = 0; i < scripts.length; i++) {
_this.redis._addedScriptHashes[scripts[i].sha] = true;
}
return execPipeline();
});
function execPipeline() {

@@ -303,0 +314,0 @@ let data = "";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.set = exports.get = exports.isPromise = void 0;
function isPromise(obj) {

@@ -4,0 +5,0 @@ return (!!obj &&

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readyHandler = exports.errorHandler = exports.closeHandler = exports.connectHandler = void 0;
const redis_errors_1 = require("redis-errors");

@@ -4,0 +5,0 @@ const command_1 = require("../command");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_REDIS_OPTIONS = void 0;
exports.DEFAULT_REDIS_OPTIONS = {

@@ -4,0 +5,0 @@ // Connection

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addTransactionSupport = void 0;
const utils_1 = require("./utils");

@@ -4,0 +5,0 @@ const standard_as_callback_1 = require("standard-as-callback");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.genRedactedString = exports.getStringValue = exports.MAX_ARGUMENT_LENGTH = void 0;
const debug_1 = require("debug");

@@ -4,0 +5,0 @@ const MAX_ARGUMENT_LENGTH = 200;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flatten = exports.noop = exports.defaults = exports.Debug = exports.zipMap = exports.CONNECTION_CLOSED_ERROR_MSG = exports.shuffle = exports.sample = exports.parseURL = exports.optimizeErrorStack = exports.toArg = exports.convertMapToArray = exports.convertObjectToArray = exports.timeout = exports.packObject = exports.isInt = exports.wrapMultiResult = exports.convertBufferToString = exports.bufferEqual = void 0;
const url_1 = require("url");
const lodash_1 = require("./lodash");
exports.defaults = lodash_1.defaults;
exports.noop = lodash_1.noop;
exports.flatten = lodash_1.flatten;
Object.defineProperty(exports, "defaults", { enumerable: true, get: function () { return lodash_1.defaults; } });
Object.defineProperty(exports, "noop", { enumerable: true, get: function () { return lodash_1.noop; } });
Object.defineProperty(exports, "flatten", { enumerable: true, get: function () { return lodash_1.flatten; } });
const debug_1 = require("./debug");

@@ -9,0 +10,0 @@ exports.Debug = debug_1.default;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flatten = exports.defaults = exports.noop = void 0;
const defaults = require("lodash.defaults");

@@ -4,0 +5,0 @@ exports.defaults = defaults;

@@ -0,1 +1,8 @@

## [4.24.3](https://github.com/luin/ioredis/compare/v4.24.2...v4.24.3) (2021-03-21)
### Bug Fixes
* support parallel script execution in pipelines ([#1304](https://github.com/luin/ioredis/issues/1304)) ([c917719](https://github.com/luin/ioredis/commit/c91771997e5e3a0196d380522b4750de9e84cc9b))
## [4.24.2](https://github.com/luin/ioredis/compare/v4.24.1...v4.24.2) (2021-03-14)

@@ -2,0 +9,0 @@

{
"name": "ioredis",
"version": "4.24.2",
"version": "4.24.3",
"description": "A robust, performance-focused and full-featured Redis client for Node.js.",

@@ -5,0 +5,0 @@ "main": "built/index.js",

@@ -151,23 +151,44 @@ [![ioredis](https://cdn.jsdelivr.net/gh/luin/ioredis@b5e8c74/logo.svg)](https://github.com/luin/ioredis)

Here is a simple example of the API for publish/subscribe.
The following program opens two client connections.
It subscribes to a channel with one connection
and publishes to that channel with the other:
Redis provides several commands for developers to implement the [Publish–subscribe pattern](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern). There are two roles in this pattern: publisher and subscriber. Publishers are not programmed to send their messages to specific subscribers. Rather, published messages are characterized into channels, without knowledge of what (if any) subscribers there may be.
By leveraging Node.js's built-in events module, ioredis makes pub/sub very straightforward to use. Below is a simple example that consists of two files, one is publisher.js that publishes messages to a channel, the other is subscriber.js that listens for messages on specific channels.
```javascript
// publisher.js
const Redis = require("ioredis");
const redis = new Redis();
const pub = new Redis();
redis.subscribe("news", "music", (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!");
setInterval(() => {
const message = { foo: Math.random() };
// Publish to my-channel-1 or my-channel-2 randomly.
const channel = `my-channel-${1 + Math.round(Math.random())}`;
// Message can be either a string or a buffer
redis.publish(channel, JSON.stringify(message));
console.log("Published %s to %s", message, channel);
}, 1000);
```
```javascript
// subscriber.js
const Redis = require("ioredis");
const redis = new Redis();
redis.subscribe("my-channel-1", "my-channel-2", (err, count) => {
if (err) {
// Just like other commands, subscribe() can fail for some reasons,
// ex network issues.
console.error("Failed to subscribe: %s", err.message);
} else {
// `count` represents the number of channels this client are currently subscribed to.
console.log(
`Subscribed successfully! This client is currently subscribed to ${count} channels.`
);
}
});
redis.on("message", (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);
console.log(`Received ${message} from ${channel}`);
});

@@ -177,11 +198,34 @@

// it returns buffers instead of strings.
// It's useful when the messages are binary data.
redis.on("messageBuffer", (channel, message) => {
// Both `channel` and `message` are buffers.
console.log(channel, message);
});
```
`PSUBSCRIBE` is also supported in a similar way:
It worth noticing that a connection (aka `Redis` instance) can't play both roles together. More specifically, when a client issues `subscribe()` or `psubscribe()`, it enters the "subscriber" mode. From that point, only commands that modify the subscription set are valid. Namely, they are: `subscribe`, `psubscribe`, `unsubscribe`, `punsubscribe`, `ping`, and `quit`. When the subscription set is empty (via `unsubscribe`/`punsubscribe`), the connection is put back into the regular mode.
If you want to do pub/sub in the same file/process, you should create a separate connection:
```javascript
const Redis = require('ioredis');
const sub = new Redis();
const pub = new Redis();
sub.subscribe(/* ... */); // From now, `sub` enters the subscriber mode.
sub.on("message", /* ... */);
setInterval(() => {
// `pub` can be used to publish messages, or send other regular commands (e.g. `hgetall`)
// because it's not in the subscriber mode.
pub.publish(/* ... */);
}, 1000);
```
`PSUBSCRIBE` is also supported in a similar way when you want to subscribe all channels whose name matches a pattern:
```javascript
redis.psubscribe("pat?ern", (err, count) => {});
// Event names are "pmessage"/"pmessageBuffer" instead of "message/messageBuffer".
redis.on("pmessage", (pattern, channel, message) => {});

@@ -191,8 +235,2 @@ redis.on("pmessageBuffer", (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.
If you need to send regular commands to Redis while in subscriber mode, just open another connection.
## Handle Binary Data

@@ -709,2 +747,3 @@

| end | emits after `close` when no more reconnections will be made, or the connection is failed to establish. |
| wait | emits when `lazyConnect` is set and will wait for the first command to be called before connecting. |

@@ -711,0 +750,0 @@ You can also check out the `Redis#status` property to get the current connection status.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc