Skip to content

Commit 0a2f4e0

Browse files
authored
use setImmediate instead of queueMicrotask (to improve performance) (redis#2516)
1 parent 2a78b48 commit 0a2f4e0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

docs/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ If don't want to queue commands in memory until a new socket is established, set
1010

1111
## How are commands batched?
1212

13-
Commands are pipelined using [`queueMicrotask`](https://nodejs.org/api/globals.html#globals_queuemicrotask_callback).
13+
Commands are pipelined using [`setImmediate`](https://nodejs.org/api/timers.html#setimmediatecallback-args).
1414

1515
If `socket.write()` returns `false`—meaning that ["all or part of the data was queued in user memory"](https://nodejs.org/api/net.html#net_socket_write_data_encoding_callback:~:text=all%20or%20part%20of%20the%20data%20was%20queued%20in%20user%20memory)—the commands will stack in memory until the [`drain`](https://nodejs.org/api/net.html#net_event_drain) event is fired.
1616

packages/client/lib/client/socket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export default class RedisSocket extends EventEmitter {
291291
this.#socket.cork();
292292
this.#isCorked = true;
293293

294-
queueMicrotask(() => {
294+
setImmediate(() => {
295295
this.#socket?.uncork();
296296
this.#isCorked = false;
297297
});

0 commit comments

Comments
 (0)