1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00
This commit is contained in:
Leibale
2024-02-28 14:33:26 -05:00
parent 88ef3b87ed
commit f9252356ae
3 changed files with 27 additions and 30 deletions

View File

@@ -83,32 +83,29 @@ for more information, see the [Scan Iterators guide](./scan-iterators.md).
## Isolation Pool
[TODO](./blocking-commands.md).
In v4, `RedisClient` had the ability to create a pool of connections using an "Isolation Pool" on top of the "main" connection. However, there was no way to use the pool without a "main" connection:
```javascript
await client.get(client.commandOptions({ isolated: true }), 'key');
const client = await createClient()
.on('error', err => console.error(err))
.connect();
await client.ping(
client.commandOptions({ isolated: true })
);
```
```javascript
await client.sendCommand(['GET', 'key']);
const pool = client.createPool({
min: 0,
max: Infinity
});
await pool.blPop('key');
await pool.sendCommand(['GET', 'key']);
await pool.use(client => client.blPop());
In v5 we've extracted this pool logic into its own class—`RedisClientPool`:
await cluster.sendCommand('key', true, ['GET', 'key']);
const clusterPool = cluster.createPool({
min: 0,
max: Infinity
});
await clusterPool.blPop('key');
await clusterPool.sendCommand('key', true, ['GET', 'key']);
await clusterPool.use(client => client.blPop());
```javascript
const pool = await createClientPool()
.on('error', err => console.error(err))
.connect();
await pool.ping();
```
See the [pool guide](./pool.md) for more information.
## Cluster `MULTI`
In v4, `cluster.multi()` did not support executing commands on replicas, even if they were readonly.

View File

@@ -22,6 +22,10 @@ await client.withTypeMapping({
}).hGetAll('key'); // Map<string, Buffer>
```
# Sentinel Support
[TODO](./sentinel.md)
# `multi.exec<'typed'>` / `multi.execTyped`
We have introduced the ability to perform a "typed" `MULTI`/`EXEC` transaction. Rather than returning `Array<ReplyUnion>`, a transaction invoked with `.exec<'typed'>` will return types appropriate to the commands in the transaction where possible:
@@ -32,7 +36,3 @@ await multi.exec(); // Array<ReplyUnion>
await multi.exec<'typed'>(); // [string]
await multi.execTyped(); // [string]
```
# Request & Reply Policies
see [here](../docs/clustering.md#command-routing).