PSUBSCRIBE(3valkey)

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

πŸ’– PSUBSCRIBE β€” the valkey manual page, but make it cute πŸ’–

okay so bestie, welcome to PSUBSCRIBE(3valkey), the valkey command that's literally just vibes-based listening. instead of following one specific channel like a normal person, you follow patterns, and valkey hits you up whenever anything matching slides into the chat. it's giving "i don't know who's gonna text me but i'll know when they do" energy. ✨


🌸 NAME 🌸

psubscribe β€” listens for messages published to channels that match one or more patterns. no cap, that's the whole job description. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

PSUBSCRIBE pattern [pattern...]

πŸ’… DESCRIPTION πŸ’…

so basically, PSUBSCRIBE subscribes the client to the given patterns. that's it, that's the tea. πŸ«–

here are the glob-style patterns it supports, and yes they're iconic:

  • h?llo subscribes to hello, hallo and hxllo
  • h*llo subscribes to hllo and heeeello
  • h[ae]llo subscribes to hello and hallo, but not hillo

use \ to escape special characters if you want to match them verbatim. periodt. πŸ’…

⚠️ once the client enters the subscribed state it is not supposed to issue any other commands, except for these lil guys: additional valkey-subscribe(7) SUBSCRIBE, valkey-ssubscribe(7) SSUBSCRIBE, PSUBSCRIBE, valkey-unsubscribe(7) UNSUBSCRIBE, valkey-sunsubscribe(7) SUNSUBSCRIBE, valkey-punsubscribe(7) PUNSUBSCRIBE, valkey-ping(7) PING, valkey-reset(7) RESET and valkey-quit(7) QUIT commands.

however, if RESP3 is used (see valkey-hello(7) HELLO) it is possible for a client to issue any commands while in subscribed state. main character privilege unlocked fr fr πŸ‘‘

note that valkey-reset(7) RESET can be called to exit subscribed state. the escape hatch, the exit interview, the "i'm leaving the group chat" button. πŸšͺ

for more information, see valkey-pubsub(7) Pub/sub. iykyk. πŸ“š


✨ REPLY ✨

when successful, this command doesn't return anything. like, nothing at all. instead, for each pattern, one message with the first element being the string psubscribe is pushed as a confirmation that the command succeeded. so you don't get an answer, you get notifications. so demure of it. πŸŽ€


πŸ”₯ COMPLEXITY πŸ”₯

O(N) where N is the number of patterns to subscribe to. so like, the more patterns you collect, the more work it does. don't be greedy bestie. πŸ’€


πŸ‘‘ ACL CATEGORIES πŸ‘‘

@pubsub @slow


🌈 HISTORY 🌈

  • Available since: 2.0.0 β€” a legend, an elder, a founding mother. she's been here since the beginning and she ate. πŸ’–

πŸŽ€ SEE ALSO πŸŽ€

the whole friend group. the squad. go say hi. 🫢


okay that's the whole page, bestie, you're officially subscribed (to knowledge). this gorgeous piece of documentation is from version 9.0.0, dated 2025-10-21, and it lives in PSUBSCRIBE(3valkey). slay, stay subscribed, and remember: patterns are just friendship with wildcards. πŸ’–βœ¨πŸ¦‹πŸŒΈπŸŽ€

πŸ“¦ where this page comes from