Redis › Pub/Sub

What is pattern based subscription using PSUBSCRIBE, and how does it differ from subscribing to specific individual channels?

Intermediate

Answer

PSUBSCRIBE lets you subscribe to multiple channels at once that match a specified wildcard pattern, rather than needing to individually subscribe to each specific channel name, which is useful when you want to receive messages from a whole category of related channels without knowing their exact names in advance.
PSUBSCRIBE news.*
-- Receives messages published to news.sports,
-- news.weather, news.technology, and any other matching channel
Real-world example A news aggregation application subscribes to all channels matching the news wildcard pattern, automatically receiving updates from any new category channel that gets created later without needing code changes.

Common follow-ups: What wildcard characters are supported in a pattern subscription?;Does pattern subscription have a performance cost compared to specific channel subscriptions?