Stream
XGROUP
Manage consumer groups for Redis streams.
Arguments
keybodystringrequired
The key of the stream.
subcommandbodyobjectrequired
The XGROUP subcommand and its parameters. Can be one of:
Response
The return type depends on the subcommand:
- CREATE: Returns "OK" string
- CREATECONSUMER: Returns 1 if created, 0 if already exists
- DELCONSUMER: Returns the number of pending messages the consumer had
- DESTROY: Returns 1 if destroyed, 0 if group didn't exist
- SETID: Returns "OK" string
Create group
const result = await redis.xgroup("mystream", { type: "CREATE", group: "mygroup", id: "$", options: { MKSTREAM: true }});Create consumer
const result = await redis.xgroup("mystream", { type: "CREATECONSUMER", group: "mygroup", consumer: "consumer1"});Delete consumer
const result = await redis.xgroup("mystream", { type: "DELCONSUMER", group: "mygroup", consumer: "consumer1"});Set group ID
const result = await redis.xgroup("mystream", { type: "SETID", group: "mygroup", id: "0-0"});Destroy group
const result = await redis.xgroup("mystream", { type: "DESTROY", group: "mygroup"});