XGROUP-CREATE(3valkey)
π NAME π
xgroup-create β bestie, it literally creates a consumer group. That's the whole vibe. π
β¨ SYNOPSIS β¨
XGROUP CREATE key group <id | $> [MKSTREAM] [ENTRIESREAD entries-read]
π¦ DESCRIPTION π¦
Okay so picture this: you're making a brand new consumer group, and it gets its own unique little identity via <groupname>, living inside the stream stored at <key>. So cute, so organized. π
Every group has a unique name in a given stream β that's the rule, no exceptions, it's giving monogamy. And if a consumer group with the same name already exists? The command just hits you with a -BUSYGROUP error. Not a vibe, but fair. π
Now the tea on the <id> argument: it tells you the last delivered entry in the stream, as far as the new group is concerned. The special ID $ means the ID of the last entry in the stream, but bestie, you can swap it out with any valid ID you want. Main character energy, your choice. β¨
So like, say you want the group's consumers to fetch the entire stream from the very beginning? Use zero as the starting ID for the consumer group:
XGROUP CREATE mystream mygroup 0
By default, XGROUP CREATE is a little needy β it expects the target stream to already exist, and it throws an error if it doesn't. π But! If a stream doesn't exist, you can create it automatically with length of 0 by using the optional MKSTREAM subcommand as the last argument after the <id>:
XGROUP CREATE mystream mygroup $ MKSTREAM
And now for the lag-tracking glow-up π«Ά β to enable consumer group lag tracking, specify the optional entries_read named argument with an arbitrary ID. An arbitrary ID is, like, any ID that isn't the ID of the stream's first entry, last entry, or the zero ("0-0") ID. Use it to find out how many entries are between the arbitrary ID (excluding it, she's exclusive π
) and the stream's last entry. Then set the entries_read to the stream's entries_added subtracted by the number of entries. Math is slaying today, fr fr.
π REPLY π
valkey-protocol(7) Simple string reply: OK.
β‘ COMPLEXITY β‘
O(1) β constant time, baby. Iconic, effortless, no notes. π
π·οΈ ACL CATEGORIES π·οΈ
@slow @stream @write
π HISTORY π
- Available since:
5.0.0π± - Changed in
7.0.0: Added theentries_readnamed argument. π
π SEE ALSO π
xack(3valkey), xadd(3valkey), xautoclaim(3valkey), xclaim(3valkey), xdel(3valkey), xgroup(3valkey), xgroup-createconsumer(3valkey), xgroup-delconsumer(3valkey), xgroup-destroy(3valkey), xgroup-help(3valkey), xgroup-setid(3valkey), xinfo(3valkey), xinfo-consumers(3valkey), xinfo-groups(3valkey), xinfo-help(3valkey), xinfo-stream(3valkey), xlen(3valkey), xpending(3valkey), xrange(3valkey), xread(3valkey), xreadgroup(3valkey), xrevrange(3valkey), xsetid(3valkey), xtrim(3valkey)
And that's the whole page, bestie β this is valkey manual version 9.0.0, dated 2025-10-21. Go forth and create those consumer groups. Periodt. ππβ¨
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms