Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

XGROUP CREATE

Last updated
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.
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.
Case RESP2 RESP3
Group created Simple string OK Simple string OK

Error replies:

  • BUSYGROUP Consumer Group name already exists
  • 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.
  • ERR Invalid stream ID specified as stream command argument
  • ERR value for ENTRIESREAD must be positive or -1
  • ERR unknown subcommand or wrong number of arguments for 'CREATE'. Try XGROUP HELP. for an unknown option.
  • WRONGTYPE if the key holds another type.
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 $ MKSTREAM
OK
127.0.0.1:6379> XGROUP CREATE orders billing 0
(error) BUSYGROUP Consumer Group name already exists
127.0.0.1:6379> XGROUP CREATE orders audit 0
OK

Same as Redis 7 and Valkey 8.

XGROUP, XGROUP SETID, XGROUP DESTROY, XREADGROUP, XINFO GROUPS