XGROUP CREATE
XGROUP CREATE key group <id | $> [MKSTREAM] [ENTRIESREAD entries-read]
- Group
- Stream
- Complexity
- O(1)
- Arity
- -5 (at least 5 words, counting the command name)
- HotKV Cloud
- All plans
- On-Premise
- no license needed
XGROUP CREATE creates the consumer group group on the stream at key. The
group delivers, through XREADGROUP with >, the
entries with an ID greater than the one you give:
$: only entries added from now on.0: every entry already in the stream, then new ones.- Any other ID: entries after it.
Options
Section titled “Options”| Option | Effect |
|---|---|
MKSTREAM |
Create an empty stream if the key does not exist. |
ENTRIESREAD entries-read |
Tell the group how many entries it has already read, so XINFO GROUPS can show its lag. -1 (the default) means unknown. |
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Group created | Simple string OK |
Simple string OK |
Error replies:
BUSYGROUP Consumer Group name already existsERR The XGROUP subcommand requires the key to exist. Note that for CREATE you may want to use the MKSTREAM option to create an empty stream automatically.ERR Invalid stream ID specified as stream command argumentERR value for ENTRIESREAD must be positive or -1ERR unknown subcommand or wrong number of arguments for 'CREATE'. Try XGROUP HELP.for an unknown option.WRONGTYPEif the key holds another type.
Examples
Section titled “Examples”127.0.0.1:6379> XGROUP CREATE orders billing $(error) ERR The XGROUP subcommand requires the key to exist. Note that for CREATE you may want to use the MKSTREAM option to create an empty stream automatically.127.0.0.1:6379> XGROUP CREATE orders billing $ MKSTREAMOK127.0.0.1:6379> XGROUP CREATE orders billing 0(error) BUSYGROUP Consumer Group name already exists127.0.0.1:6379> XGROUP CREATE orders audit 0OKCompatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”XGROUP, XGROUP SETID, XGROUP DESTROY, XREADGROUP, XINFO GROUPS
Was this page helpful?
Thanks for the feedback.