MCPcopy
hub / github.com/socketio/socket.io / XADD

Function XADD

packages/socket.io-redis-streams-emitter/lib/util.ts:46–68  ·  view source on GitHub ↗
(
  redisClient: any,
  streamName: string,
  payload: any,
  maxLenThreshold: number,
)

Source from the content-addressed store, hash-verified

44 * @see https://redis.io/commands/xadd/
45 */
46export 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}

Callers 1

publishMethod · 0.90

Calls 2

isRedisV4ClientFunction · 0.85
keysMethod · 0.80

Tested by

no test coverage detected