Socket
Socket
Sign inDemoInstall

redis

Package Overview
Dependencies
Maintainers
3
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis - npm Package Compare versions

Comparing version 4.5.1 to 4.6.5

8

dist/index.d.ts

@@ -186,2 +186,4 @@ import { RedisModules, RedisFunctions, RedisScripts, RedisClientOptions, RedisClientType as _RedisClientType, RedisClusterOptions, RedisClusterType as _RedisClusterType } from '@redis/client';

add: typeof import("@redis/bloom/dist/commands/bloom/ADD");
CARD: typeof import("@redis/bloom/dist/commands/bloom/CARD");
card: typeof import("@redis/bloom/dist/commands/bloom/CARD");
EXISTS: typeof import("@redis/bloom/dist/commands/bloom/EXISTS");

@@ -291,6 +293,6 @@ exists: typeof import("@redis/bloom/dist/commands/bloom/EXISTS");

};
export declare type RedisDefaultModules = typeof modules;
export declare type RedisClientType<M extends RedisModules = RedisDefaultModules, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> = _RedisClientType<M, F, S>;
export type RedisDefaultModules = typeof modules;
export type RedisClientType<M extends RedisModules = RedisDefaultModules, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> = _RedisClientType<M, F, S>;
export declare function createClient<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts>(options?: RedisClientOptions<M, F, S>): _RedisClientType<RedisDefaultModules & M, F, S>;
export declare type RedisClusterType<M extends RedisModules = RedisDefaultModules, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> = _RedisClusterType<M, F, S>;
export type RedisClusterType<M extends RedisModules = RedisDefaultModules, F extends RedisFunctions = Record<string, never>, S extends RedisScripts = Record<string, never>> = _RedisClusterType<M, F, S>;
export declare function createCluster<M extends RedisModules, F extends RedisFunctions, S extends RedisScripts>(options: RedisClusterOptions<M, F, S>): RedisClusterType<RedisDefaultModules & M, F, S>;
{
"name": "redis",
"description": "A modern, high performance Redis client",
"version": "4.5.1",
"version": "4.6.5",
"license": "MIT",

@@ -26,7 +26,7 @@ "main": "./dist/index.js",

"dependencies": {
"@redis/bloom": "1.1.0",
"@redis/client": "1.4.2",
"@redis/bloom": "1.2.0",
"@redis/client": "1.5.6",
"@redis/graph": "1.1.0",
"@redis/json": "1.0.4",
"@redis/search": "1.1.0",
"@redis/search": "1.1.2",
"@redis/time-series": "1.0.4"

@@ -36,5 +36,5 @@ },

"@tsconfig/node14": "^1.0.3",
"gh-pages": "^4.0.0",
"release-it": "^15.3.0",
"typescript": "^4.7.4"
"gh-pages": "^5.0.0",
"release-it": "^15.6.0",
"typescript": "^4.9.5"
},

@@ -48,3 +48,6 @@ "repository": {

},
"homepage": "https://github.com/redis/node-redis"
"homepage": "https://github.com/redis/node-redis",
"keywords": [
"redis"
]
}
# Node-Redis
[![Tests](https://img.shields.io/github/workflow/status/redis/node-redis/Tests/master.svg?label=tests)](https://github.com/redis/node-redis/actions/workflows/tests.yml)
[![Tests](https://img.shields.io/github/actions/workflow/status/redis/node-redis/tests.yml?branch=master)](https://github.com/redis/node-redis/actions/workflows/tests.yml)
[![Coverage](https://codecov.io/gh/redis/node-redis/branch/master/graph/badge.svg?token=xcfqHhJC37)](https://codecov.io/gh/redis/node-redis)
[![License](https://img.shields.io/github/license/redis/node-redis.svg)](https://github.com/redis/node-redis/blob/master/LICENSE)
[![LGTM alerts](https://img.shields.io/lgtm/alerts/g/redis/node-redis.svg?logo=LGTM)](https://lgtm.com/projects/g/redis/node-redis/alerts)

@@ -32,2 +31,10 @@ [![Discord](https://img.shields.io/discord/697882427875393627.svg?style=social&logo=discord)](https://discord.gg/redis)

Start a redis via docker:
``` bash
docker run -p 6379:6379 -it redis/redis-stack-server:latest
```
To install node-redis, simply:
```bash

@@ -50,3 +57,3 @@ npm install redis

client.on('error', (err) => console.log('Redis Client Error', err));
client.on('error', err => console.log('Redis Client Error', err));

@@ -70,2 +77,4 @@ await client.connect();

To check if the the client is connected and ready to send commands, use `client.isReady` which returns a boolean. `client.isOpen` is also available. This returns `true` when the client's underlying socket is open, and `false` when it isn't (for example when the client is still connecting or reconnecting after a network error).
### Redis Commands

@@ -163,44 +172,4 @@

Subscribing to a channel requires a dedicated stand-alone connection. You can easily get one by `.duplicate()`ing an existing Redis connection.
See the [Pub/Sub overview](./docs/pub-sub.md).
```typescript
const subscriber = client.duplicate();
await subscriber.connect();
```
Once you have one, simply subscribe and unsubscribe as needed:
```typescript
await subscriber.subscribe('channel', (message) => {
console.log(message); // 'message'
});
await subscriber.pSubscribe('channe*', (message, channel) => {
console.log(message, channel); // 'message', 'channel'
});
await subscriber.unsubscribe('channel');
await subscriber.pUnsubscribe('channe*');
```
Publish a message on a channel:
```typescript
await publisher.publish('channel', 'message');
```
There is support for buffers as well:
```typescript
await subscriber.subscribe('channel', (message) => {
console.log(message); // <Buffer 6d 65 73 73 61 67 65>
}, true);
await subscriber.pSubscribe('channe*', (message, channel) => {
console.log(message, channel); // <Buffer 6d 65 73 73 61 67 65>, <Buffer 63 68 61 6e 6e 65 6c>
}, true);
```
### Scan Iterator

@@ -371,12 +340,15 @@

| Event name | Scenes | Arguments to be passed to the listener |
|----------------|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| `connect` | The client is initiating a connection to the server. | _No argument_ |
| `ready` | The client successfully initiated the connection to the server. | _No argument_ |
| `end` | The client disconnected the connection to the server via `.quit()` or `.disconnect()`. | _No argument_ |
| `error` | When a network error has occurred, such as unable to connect to the server or the connection closed unexpectedly. | 1 argument: The error object, such as `SocketClosedUnexpectedlyError: Socket closed unexpectedly` or `Error: connect ECONNREFUSED [IP]:[PORT]` |
| `reconnecting` | The client is trying to reconnect to the server. | _No argument_ |
| Name | When | Listener arguments |
|-------------------------|------------------------------------------------------------------------------------|------------------------------------------------------------|
| `connect` | Initiating a connection to the server | *No arguments* |
| `ready` | Client is ready to use | *No arguments* |
| `end` | Connection has been closed (via `.quit()` or `.disconnect()`) | *No arguments* |
| `error` | An error has occurred—usually a network issue such as "Socket closed unexpectedly" | `(error: Error)` |
| `reconnecting` | Client is trying to reconnect to the server | *No arguments* |
| `sharded-channel-moved` | See [here](./docs/pub-sub.md#sharded-channel-moved-event) | See [here](./docs/pub-sub.md#sharded-channel-moved-event) |
The client will not emit [any other events](./docs/v3-to-v4.md#all-the-removed-events) beyond those listed above.
> :warning: You **MUST** listen to `error` events. If a client doesn't have at least one `error` listener registered and an `error` occurs, that error will be thrown and the Node.js process will exit. See the [`EventEmitter` docs](https://nodejs.org/api/events.html#events_error_events) for more details.
> The client will not emit [any other events](./docs/v3-to-v4.md#all-the-removed-events) beyond those listed above.
## Supported Redis versions

@@ -383,0 +355,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc