You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
docs
This commit is contained in:
@@ -83,32 +83,29 @@ for more information, see the [Scan Iterators guide](./scan-iterators.md).
|
|||||||
|
|
||||||
## Isolation Pool
|
## 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
|
```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
|
In v5 we've extracted this pool logic into its own class—`RedisClientPool`:
|
||||||
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());
|
|
||||||
|
|
||||||
await cluster.sendCommand('key', true, ['GET', 'key']);
|
```javascript
|
||||||
const clusterPool = cluster.createPool({
|
const pool = await createClientPool()
|
||||||
min: 0,
|
.on('error', err => console.error(err))
|
||||||
max: Infinity
|
.connect();
|
||||||
});
|
|
||||||
await clusterPool.blPop('key');
|
await pool.ping();
|
||||||
await clusterPool.sendCommand('key', true, ['GET', 'key']);
|
|
||||||
await clusterPool.use(client => client.blPop());
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
See the [pool guide](./pool.md) for more information.
|
||||||
|
|
||||||
## Cluster `MULTI`
|
## Cluster `MULTI`
|
||||||
|
|
||||||
In v4, `cluster.multi()` did not support executing commands on replicas, even if they were readonly.
|
In v4, `cluster.multi()` did not support executing commands on replicas, even if they were readonly.
|
||||||
|
@@ -22,6 +22,10 @@ await client.withTypeMapping({
|
|||||||
}).hGetAll('key'); // Map<string, Buffer>
|
}).hGetAll('key'); // Map<string, Buffer>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Sentinel Support
|
||||||
|
|
||||||
|
[TODO](./sentinel.md)
|
||||||
|
|
||||||
# `multi.exec<'typed'>` / `multi.execTyped`
|
# `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:
|
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.exec<'typed'>(); // [string]
|
||||||
await multi.execTyped(); // [string]
|
await multi.execTyped(); // [string]
|
||||||
```
|
```
|
||||||
|
|
||||||
# Request & Reply Policies
|
|
||||||
|
|
||||||
see [here](../docs/clustering.md#command-routing).
|
|
||||||
|
@@ -28,12 +28,6 @@ createClient({
|
|||||||
|
|
||||||
You can also use discrete parameters, UNIX sockets, and even TLS to connect. Details can be found in the [client configuration guide](../../docs/client-configuration.md).
|
You can also use discrete parameters, UNIX sockets, and even TLS to connect. Details can be found in the [client configuration guide](../../docs/client-configuration.md).
|
||||||
|
|
||||||
### Connection State
|
|
||||||
|
|
||||||
To client exposes 2 `boolean`s that track the client state:
|
|
||||||
1. `isOpen` - the client is either connecting or connected.
|
|
||||||
2. `isReady` - the client is connected and ready to send
|
|
||||||
|
|
||||||
### Redis Commands
|
### Redis Commands
|
||||||
|
|
||||||
There is built-in support for all of the [out-of-the-box Redis commands](https://redis.io/commands). They are exposed using the raw Redis command names (`HSET`, `HGETALL`, etc.) and a friendlier camel-cased version (`hSet`, `hGetAll`, etc.):
|
There is built-in support for all of the [out-of-the-box Redis commands](https://redis.io/commands). They are exposed using the raw Redis command names (`HSET`, `HGETALL`, etc.) and a friendlier camel-cased version (`hSet`, `hGetAll`, etc.):
|
||||||
@@ -148,6 +142,12 @@ await Promise.all([
|
|||||||
]);
|
]);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Connection State
|
||||||
|
|
||||||
|
To client exposes 2 `boolean`s that track the client state:
|
||||||
|
1. `isOpen` - the client is either connecting or connected.
|
||||||
|
2. `isReady` - the client is connected and ready to send
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
The client extends `EventEmitter` and emits the following events:
|
The client extends `EventEmitter` and emits the following events:
|
||||||
|
Reference in New Issue
Block a user