Skip to content

Commit 58bf53c

Browse files
Merge pull request #1385 from richardhenry/patch-1
Add executeIsolated recommendation to node-redis docs
2 parents a47d3c1 + be96761 commit 58bf53c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

content/develop/clients/nodejs/transpipe.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,29 @@ const updatedPath = await client.get('shellpath');
152152
console.log(updatedPath);
153153
// >>> /usr/syscmds/:/usr/mycmds/
154154
```
155+
156+
In an environment where multiple concurrent requests are sharing a connection
157+
(such as a web server), you must wrap the above transaction logic in a call to
158+
`client.executeIsolated` to get an isolated connection, like so:
159+
160+
```js
161+
await client.executeIsolated(async (client) => {
162+
await client.watch('shellpath');
163+
// ...
164+
})
165+
```
166+
167+
This is important because the server tracks the state of the WATCH on a
168+
per-connection basis, and concurrent WATCH and MULTI/EXEC calls on the same
169+
connection will interfere with one another.
170+
171+
You can configure the size of the isolation pool when calling `createClient`:
172+
173+
```js
174+
const client = createClient({
175+
isolationPoolOptions: {
176+
min: 1,
177+
max: 100,
178+
},
179+
})
180+
```

0 commit comments

Comments
 (0)