( redisClient: any, streamName: string, payload: any, maxLenThreshold: number, )
| 44 | * @see https://redis.io/commands/xadd/ |
| 45 | */ |
| 46 | export function XADD( |
| 47 | redisClient: any, |
| 48 | streamName: string, |
| 49 | payload: any, |
| 50 | maxLenThreshold: number, |
| 51 | ) { |
| 52 | if (isRedisV4Client(redisClient)) { |
| 53 | return redisClient.xAdd(streamName, "*", payload, { |
| 54 | TRIM: { |
| 55 | strategy: "MAXLEN", |
| 56 | strategyModifier: "~", |
| 57 | threshold: maxLenThreshold, |
| 58 | }, |
| 59 | }); |
| 60 | } else { |
| 61 | const args = [streamName, "MAXLEN", "~", maxLenThreshold, "*"]; |
| 62 | Object.keys(payload).forEach((k) => { |
| 63 | args.push(k, payload[k]); |
| 64 | }); |
| 65 | |
| 66 | return redisClient.xadd.call(redisClient, args); |
| 67 | } |
| 68 | } |
no test coverage detected