Skip to content

Commit 0752f14

Browse files
leibalechayim
andauthored
prepare 4.1.0 (#2111)
* increase test coverage * @node-redis to @redis * ugprade deps * fix benchmark * use 7.0 docker (not rc), update readmes, clean code, fix @-redis import * update readme * fix function in cluster * update docs Co-authored-by: Chayim <[email protected]> * Update clustering.md * add subpackages move warning * drop support for node 12 * upgrade deps * fix tsconfig.base.json Co-authored-by: Chayim <[email protected]>
1 parent baf67fd commit 0752f14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3860
-1856
lines changed

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
node-version: ['12', '14', '16']
20-
redis-version: ['5', '6.0', '6.2', '7.0-rc3']
19+
node-version: ['14', '16', '17', '18']
20+
redis-version: ['5', '6.0', '6.2', '7.0']
2121
steps:
2222
- uses: actions/[email protected]
2323
with:

README.md

+83-28
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,28 @@
44
[![Coverage](https://codecov.io/gh/redis/node-redis/branch/master/graph/badge.svg?token=xcfqHhJC37)](https://codecov.io/gh/redis/node-redis)
55
[![License](https://img.shields.io/github/license/redis/node-redis.svg)](https://github.com/redis/node-redis/blob/master/LICENSE)
66
[![LGTM alerts](https://img.shields.io/lgtm/alerts/g/redis/node-redis.svg?logo=LGTM)](https://lgtm.com/projects/g/redis/node-redis/alerts)
7-
[![Chat](https://img.shields.io/discord/697882427875393627.svg)](https://discord.gg/redis)
87

9-
node-redis is a modern, high performance [Redis](https://redis.io) client for Node.js with built-in support for Redis 6.2 commands and modules including [RediSearch](https://redisearch.io) and [RedisJSON](https://redisjson.io).
8+
[![Discord](https://img.shields.io/discord/697882427875393627.svg?style=social&logo=discord)](https://discord.gg/redis)
9+
[![Twitch](https://img.shields.io/twitch/status/redisinc?style=social)](https://www.twitch.tv/redisinc)
10+
[![YouTube](https://img.shields.io/youtube/channel/views/UCD78lHSwYqMlyetR0_P4Vig?style=social)](https://www.youtube.com/redisinc)
11+
[![Twitter](https://img.shields.io/twitter/follow/redisinc?style=social)](https://twitter.com/redisinc)
12+
13+
node-redis is a modern, high performance [Redis](https://redis.io) client for Node.js.
1014

1115

1216
## Packages
1317

14-
| Name | Description |
15-
|---------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
16-
| [redis](./) | [![Downloads](https://img.shields.io/npm/dm/redis.svg)](https://www.npmjs.com/package/redis) [![Version](https://img.shields.io/npm/v/redis.svg)](https://www.npmjs.com/package/redis) |
17-
| [@node-redis/client](./packages/client) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/client.svg)](https://www.npmjs.com/package/@node-redis/client) [![Version](https://img.shields.io/npm/v/@node-redis/client.svg)](https://www.npmjs.com/package/@node-redis/client) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/client/) |
18-
| [@node-redis/bloom](./packages/bloom) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/bloom.svg)](https://www.npmjs.com/package/@node-redis/bloom) [![Version](https://img.shields.io/npm/v/@node-redis/bloom.svg)](https://www.npmjs.com/package/@node-redis/bloom) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/bloom/) [Redis Bloom](https://oss.redis.com/redisbloom/) commands |
19-
| [@node-redis/graph](./packages/graph) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/graph.svg)](https://www.npmjs.com/package/@node-redis/graph) [![Version](https://img.shields.io/npm/v/@node-redis/graph.svg)](https://www.npmjs.com/package/@node-redis/graph) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/graph/) [Redis Graph](https://oss.redis.com/redisgraph/) commands |
20-
| [@node-redis/json](./packages/json) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/json.svg)](https://www.npmjs.com/package/@node-redis/json) [![Version](https://img.shields.io/npm/v/@node-redis/json.svg)](https://www.npmjs.com/package/@node-redis/json) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/json/) [Redis JSON](https://oss.redis.com/redisjson/) commands |
21-
| [@node-redis/search](./packages/search) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/search.svg)](https://www.npmjs.com/package/@node-redis/search) [![Version](https://img.shields.io/npm/v/@node-redis/search.svg)](https://www.npmjs.com/package/@node-redis/search) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/search/) [Redis Search](https://oss.redis.com/redisearch/) commands |
22-
| [@node-redis/time-series](./packages/time-series) | [![Downloads](https://img.shields.io/npm/dm/@node-redis/time-series.svg)](https://www.npmjs.com/package/@node-redis/time-series) [![Version](https://img.shields.io/npm/v/@node-redis/time-series.svg)](https://www.npmjs.com/package/@node-redis/time-series) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/time-series/) [Redis Time-Series](https://oss.redis.com/redistimeseries/) commands |
18+
| Name | Description |
19+
|----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
20+
| [redis](./) | [![Downloads](https://img.shields.io/npm/dm/redis.svg)](https://www.npmjs.com/package/redis) [![Version](https://img.shields.io/npm/v/redis.svg)](https://www.npmjs.com/package/redis) |
21+
| [@redis/client](./packages/client) | [![Downloads](https://img.shields.io/npm/dm/@redis/client.svg)](https://www.npmjs.com/package/@redis/client) [![Version](https://img.shields.io/npm/v/@redis/client.svg)](https://www.npmjs.com/package/@redis/client) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/client/) |
22+
| [@redis/bloom](./packages/bloom) | [![Downloads](https://img.shields.io/npm/dm/@redis/bloom.svg)](https://www.npmjs.com/package/@redis/bloom) [![Version](https://img.shields.io/npm/v/@redis/bloom.svg)](https://www.npmjs.com/package/@redis/bloom) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/bloom/) [Redis Bloom](https://oss.redis.com/redisbloom/) commands |
23+
| [@redis/graph](./packages/graph) | [![Downloads](https://img.shields.io/npm/dm/@redis/graph.svg)](https://www.npmjs.com/package/@redis/graph) [![Version](https://img.shields.io/npm/v/@redis/graph.svg)](https://www.npmjs.com/package/@redis/graph) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/graph/) [Redis Graph](https://oss.redis.com/redisgraph/) commands |
24+
| [@redis/json](./packages/json) | [![Downloads](https://img.shields.io/npm/dm/@redis/json.svg)](https://www.npmjs.com/package/@redis/json) [![Version](https://img.shields.io/npm/v/@redis/json.svg)](https://www.npmjs.com/package/@redis/json) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/json/) [Redis JSON](https://oss.redis.com/redisjson/) commands |
25+
| [@redis/search](./packages/search) | [![Downloads](https://img.shields.io/npm/dm/@redis/search.svg)](https://www.npmjs.com/package/@redis/search) [![Version](https://img.shields.io/npm/v/@redis/search.svg)](https://www.npmjs.com/package/@redis/search) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/search/) [Redis Search](https://oss.redis.com/redisearch/) commands |
26+
| [@redis/time-series](./packages/time-series) | [![Downloads](https://img.shields.io/npm/dm/@redis/time-series.svg)](https://www.npmjs.com/package/@redis/time-series) [![Version](https://img.shields.io/npm/v/@redis/time-series.svg)](https://www.npmjs.com/package/@redis/time-series) [![Docs](https://img.shields.io/badge/-documentation-dc382c)](https://redis.js.org/documentation/time-series/) [Redis Time-Series](https://oss.redis.com/redistimeseries/) commands |
27+
28+
> :warning: In version 4.1.0 we moved our subpackages from `@node-redis` to `@redis`. If you're just using `npm install redis`, you don't need to do anything—it'll upgrade automatically. If you're using the subpackages directly, you'll need to point to the new scope (e.g. `@redis/client` instead of `@node-redis/client`).
2329
2430
## Installation
2531

@@ -219,36 +225,84 @@ client.scanIterator({
219225
});
220226
```
221227

222-
### Lua Scripts
228+
### [Programmability](https://redis.io/docs/manual/programmability/)
229+
230+
Redis provides a programming interface allowing code execution on the redis server.
231+
232+
#### [Functions](https://redis.io/docs/manual/programmability/functions-intro/)
233+
234+
The following example retrieves a key in redis, returning the value of the key, incremented by an integer. For example, if your key _foo_ has the value _17_ and we run `add('foo', 25)`, it returns the answer to Life, the Universe and Everything.
235+
236+
```lua
237+
#!lua name=library
238+
239+
redis.register_function {
240+
function_name = 'add',
241+
callback = function(keys, args) return redis.call('GET', keys[1]) + args[1] end,
242+
flags = { 'no-writes' }
243+
}
244+
```
245+
246+
Here is the same example, but in a format that can be pasted into the `redis-cli`.
223247

224-
Define new functions using [Lua scripts](https://redis.io/commands/eval) which execute on the Redis server:
248+
```
249+
FUNCTION LOAD "#!lua name=library\nredis.register_function{function_name=\"add\", callback=function(keys, args) return redis.call('GET', keys[1])+args[1] end, flags={\"no-writes\"}}"
250+
```
251+
252+
Load the prior redis function on the _redis server_ before running the example below.
225253

226254
```typescript
227-
import { createClient, defineScript } from 'redis';
255+
import { createClient } from 'redis';
228256

229-
(async () => {
230-
const client = createClient({
231-
scripts: {
232-
add: defineScript({
257+
const client = createClient({
258+
functions: {
259+
library: {
260+
add: {
233261
NUMBER_OF_KEYS: 1,
234-
SCRIPT:
235-
'local val = redis.pcall("GET", KEYS[1]);' +
236-
'return val + ARGV[1];',
237262
transformArguments(key: string, toAdd: number): Array<string> {
238263
return [key, toAdd.toString()];
239264
},
240265
transformReply(reply: number): number {
241266
return reply;
242267
}
243-
})
268+
}
244269
}
245-
});
270+
}
271+
});
272+
273+
await client.connect();
274+
275+
await client.set('key', '1');
276+
await client.library.add('key', 2); // 3
277+
```
278+
279+
#### [Lua Scripts](https://redis.io/docs/manual/programmability/eval-intro/)
246280

247-
await client.connect();
281+
The following is an end-to-end example of the prior concept.
282+
283+
```typescript
284+
import { createClient, defineScript } from 'redis';
285+
286+
const client = createClient({
287+
scripts: {
288+
add: defineScript({
289+
NUMBER_OF_KEYS: 1,
290+
SCRIPT:
291+
'return redis.call("GET", KEYS[1]) + ARGV[1];',
292+
transformArguments(key: string, toAdd: number): Array<string> {
293+
return [key, toAdd.toString()];
294+
},
295+
transformReply(reply: number): number {
296+
return reply;
297+
}
298+
})
299+
}
300+
});
301+
302+
await client.connect();
248303

249-
await client.set('key', '1');
250-
await client.add('key', 2); // 3
251-
})();
304+
await client.set('key', '1');
305+
await client.add('key', 2); // 3
252306
```
253307

254308
### Disconnecting
@@ -323,9 +377,10 @@ Node Redis is supported with the following versions of Redis:
323377

324378
| Version | Supported |
325379
|---------|--------------------|
380+
| 7.0.z | :heavy_check_mark: |
326381
| 6.2.z | :heavy_check_mark: |
327382
| 6.0.z | :heavy_check_mark: |
328-
| 5.y.z | :heavy_check_mark: |
383+
| 5.0.z | :heavy_check_mark: |
329384
| < 5.0 | :x: |
330385

331386
> Node Redis should work with older versions of Redis, but it is not fully tested and we cannot offer support.

benchmark/lib/ping/v4.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createClient } from '@node-redis/client';
1+
import { createClient } from '@redis/client';
22

33
export default async (host) => {
44
const client = createClient({

benchmark/lib/set-get-delete-string/v4.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createClient } from '@node-redis/client';
1+
import { createClient } from '@redis/client';
22

33
export default async (host, { randomString }) => {
44
const client = createClient({

0 commit comments

Comments
 (0)