Skip to content

Commit

Permalink
refactor: remove redis import
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed May 7, 2024
1 parent 2013436 commit 834d3d5
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { randomBytes } from "crypto";
import { commandOptions } from "redis";

export function hasBinary(obj: any, toJSON?: boolean): boolean {
if (!obj || typeof obj !== "object") {
Expand Down Expand Up @@ -74,21 +73,23 @@ export function XREAD(
readCount: number
) {
if (isRedisV4Client(redisClient)) {
return redisClient.xRead(
commandOptions({
isolated: true,
}),
[
return import("redis").then((redisPackage) => {
return redisClient.xRead(
redisPackage.commandOptions({
isolated: true,
}),
[
{
key: streamName,
id: offset,
},
],
{
key: streamName,
id: offset,
},
],
{
COUNT: readCount,
BLOCK: 5000,
}
);
COUNT: readCount,
BLOCK: 5000,
}
);
});
} else {
return redisClient
.xread("BLOCK", 100, "COUNT", readCount, "STREAMS", streamName, offset)
Expand Down

0 comments on commit 834d3d5

Please sign in to comment.