XGROUP-CREATE(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’– 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 the entries_read named 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