We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1921b51 commit 1c206b1Copy full SHA for 1c206b1
lib/util.ts
@@ -57,6 +57,8 @@ function mapResult(result) {
57
};
58
}
59
60
+const POOL = Symbol("redis-v5-pool");
61
+
62
/**
63
* @see https://redis.io/commands/xread/
64
*/
@@ -68,6 +70,28 @@ export function XREAD(
68
70
blockTimeInMs: number
69
71
) {
72
if (isNodeRedisClient(redisClient)) {
73
+ if (typeof redisClient.createPool === "function") {
74
+ if (!redisClient[POOL]) {
75
+ redisClient[POOL] = redisClient.createPool();
76
77
+ redisClient.on("end", () => {
78
+ redisClient[POOL].destroy();
79
+ });
80
+ }
81
82
+ return redisClient[POOL].xRead(
83
+ [
84
+ {
85
+ key: streamName,
86
+ id: offset,
87
+ },
88
+ ],
89
90
+ COUNT: readCount,
91
+ BLOCK: blockTimeInMs,
92
93
+ );
94
95
return redisClient.xRead(
96
[
97
{
0 commit comments