Skip to content

Commit b3f69e2

Browse files
committed
more v5 docs updates
1 parent 53e3575 commit b3f69e2

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,13 @@ await client.hVals("key"); // ['value1', 'value2']
124124
`Buffer`s are supported as well:
125125

126126
```typescript
127+
const client = createClient().withTypeMapping({
128+
[RESP_TYPES.BLOB_STRING]: Buffer
129+
});
130+
127131
await client.hSet("key", "field", Buffer.from("value")); // 'OK'
128-
await client.hGetAll(commandOptions({ returnBuffers: true }), "key"); // { field: <Buffer 76 61 6c 75 65> }
132+
await client.hGet("key", "field"); // { field: <Buffer 76 61 6c 75 65> }
133+
129134
```
130135

131136
### Unsupported Redis Commands

docs/RESP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ By default, each type is mapped to the first option in the lists below. To chang
2323
- Double (`,`) => `number | string`
2424
- Simple String (`+`) => `string | Buffer`
2525
- Blob String (`$`) => `string | Buffer`
26-
- Verbatim String (`=`) => `string | Buffer | VerbatimString` (TODO: `VerbatimString` typedoc link)
26+
- Verbatim String (`=`) => `string | Buffer | VerbatimString`
2727
- Simple Error (`-`) => `ErrorReply`
2828
- Blob Error (`!`) => `ErrorReply`
2929
- Array (`*`) => `Array`

docs/v5.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,83 @@
11
# RESP3 Support
22

3-
TODO
3+
Node Redis v5 adds support for [RESP3](https://github.com/redis/redis-specifications/blob/master/protocol/RESP3.md), the new Redis serialization protocol. RESP3 offers richer data types and improved type handling compared to RESP2.
4+
5+
To use RESP3, specify it when creating your client:
46

57
```javascript
8+
import { createClient } from 'redis';
9+
610
const client = createClient({
711
RESP: 3
812
});
913
```
1014

15+
## Type Mapping
16+
17+
With RESP3, you can leverage the protocol's richer type system. You can customize how different Redis types are represented in JavaScript using type mapping:
18+
1119
```javascript
12-
// by default
20+
import { createClient, TYPES } from 'redis';
21+
22+
// By default
1323
await client.hGetAll('key'); // Record<string, string>
1424

25+
// Use Map instead of plain object
1526
await client.withTypeMapping({
1627
[TYPES.MAP]: Map
1728
}).hGetAll('key'); // Map<string, string>
1829

30+
// Use both Map and Buffer
1931
await client.withTypeMapping({
2032
[TYPES.MAP]: Map,
2133
[TYPES.BLOB_STRING]: Buffer
2234
}).hGetAll('key'); // Map<string, Buffer>
2335
```
2436

37+
This replaces the previous approach of using `commandOptions({ returnBuffers: true })` in v4.
38+
39+
## PubSub in RESP3
40+
41+
RESP3 uses a different mechanism for handling Pub/Sub messages. Instead of modifying the `onReply` handler as in RESP2, RESP3 provides a dedicated `onPush` handler. When using RESP3, the client automatically uses this more efficient push notification system.
42+
43+
## Known Limitations
44+
45+
### Unstable Module Commands
46+
47+
Some Redis module commands have unstable RESP3 transformations. These commands will throw an error when used with RESP3 unless you explicitly opt in to using them by setting `unstableResp3: true` in your client configuration:
48+
49+
```javascript
50+
const client = createClient({
51+
RESP: 3,
52+
unstableResp3: true
53+
});
54+
```
55+
56+
The following commands have unstable RESP3 implementations:
57+
58+
1. **Stream Commands**:
59+
- `XREAD` and `XREADGROUP` - The response format differs between RESP2 and RESP3
60+
61+
2. **Search Commands (RediSearch)**:
62+
- `FT.AGGREGATE`
63+
- `FT.AGGREGATE_WITHCURSOR`
64+
- `FT.CURSOR_READ`
65+
- `FT.INFO`
66+
- `FT.PROFILE_AGGREGATE`
67+
- `FT.PROFILE_SEARCH`
68+
- `FT.SEARCH`
69+
- `FT.SEARCH_NOCONTENT`
70+
- `FT.SPELLCHECK`
71+
72+
3. **Time Series Commands**:
73+
- `TS.INFO`
74+
- `TS.INFO_DEBUG`
75+
76+
If you need to use these commands with RESP3, be aware that the response format might change in future versions.
77+
2578
# Sentinel Support
2679

27-
[TODO](./sentinel.md)
80+
[Sentinel](./sentinel.md)
2881

2982
# `multi.exec<'typed'>` / `multi.execTyped`
3083

0 commit comments

Comments
 (0)