Nobody has actually asked these questions. But, we needed somewhere to put all the important bits and bobs that didn't fit anywhere else. So, here you go!
When a socket closes unexpectedly, all the commands that were already sent will reject as they might have been executed on the server. The rest will remain queued in memory until a new socket is established. If the client is closed—either by returning an error from reconnectStrategy
or by manually calling .disconnect()
—they will be rejected.
If don't want to queue commands in memory until a new socket is established, set the disableOfflineQueue
option to true
in the client configuration. This will result in those commands being rejected.
Commands are pipelined using setImmediate
.
If socket.write()
returns false
—meaning that "all or part of the data was queued in user memory"—the commands will stack in memory until the drain
event is fired.
Redis has support for modules and running Lua scripts within the Redis context. To take advantage of typing within these scenarios, RedisClient
and RedisCluster
should be used with typeof, rather than the base types RedisClientType
and RedisClusterType
.
import { createClient } from '@redis/client';
export const client = createClient();
export type RedisClientType = typeof client;