Home / Use Cases / Pub/Sub

Redis Pub/Sub vs Memcached: There's No Contest (2026)

Short answer: Memcached does not support pub/sub. It is a key-value cache only. For pub/sub use Redis (fire-and-forget), Redis Streams (persistent + consumer groups), Valkey (same as Redis 7.2 baseline), or a dedicated message broker (Kafka, NATS, RabbitMQ).

Which pub/sub mechanism you pick depends on whether you need persistence and consumer groups. Here is the decision tree.

Redis Pub/Sub: fire-and-forget

SUBSCRIBE / PUBLISH semantics. A publisher sends a message to a channel; all active subscribers receive it. Fire-and-forget: if no subscriber is listening when the message arrives, it is dropped. No persistence, no replay. Pattern subscriptions (PSUBSCRIBE) match channels by glob pattern.

Real users: Discord uses Redis pub/sub for real-time presence signals. Slack has historically used Redis pub/sub for typing indicators and read receipts. Source: redis.io/docs/pubsub

// Node.js with ioredis — pub/sub
import Redis from 'ioredis';

const sub = new Redis();
const pub = new Redis();

// Subscriber
sub.subscribe('notifications', (err, count) => {
  console.log(`Subscribed to ${count} channels`);
});

sub.on('message', (channel, message) => {
  console.log(`[${channel}] ${message}`);
});

// Publisher
pub.publish('notifications', JSON.stringify({
  type: 'user.signup',
  userId: '42',
  timestamp: Date.now(),
}));

// Valkey: identical API, drop-in compatible

Redis Streams: persistent, consumer groups

XADD / XREAD / XGROUP. Persistent log: messages are stored in Redis until explicitly acknowledged or trimmed. Consumer groups allow one message to be delivered to exactly one consumer in a group (fan-out to groups, at-most-once within a group). At-least-once delivery with XACK. Replay available via XRANGE.

# Redis Streams — producer
XADD events * type user.signup userId 42 email ada@example.com

# Create consumer group at the beginning of stream
XGROUP CREATE events workers $ MKSTREAM

# Consumer reads next unacknowledged message
XREADGROUP GROUP workers consumer-1 COUNT 1 STREAMS events >

# Acknowledge processed message (at-least-once)
XACK events workers 1746123456789-0

# Replay: read all messages since a given ID
XRANGE events 0 + COUNT 100

Valkey supports Redis Streams fully (equivalent to Redis 7.2 baseline). XADD, XREAD, XGROUP, XACK all work identically.

Which one to use?

Use Redis Pub/Sub when:

  • Ephemeral notifications (typing indicator, presence, live cursor)
  • High volume, no replay needed
  • Subscribers are always online
  • Fire-and-forget is acceptable (missed messages are OK)

Use Redis Streams when:

  • Job queues with at-least-once delivery
  • Event sourcing (you need replay)
  • Audit log (messages must persist)
  • Consumer group coordination (N consumers, each message processed once)

Use Kafka or NATS when:

  • Cross-datacenter durability required
  • Exactly-once delivery semantics
  • Multi-tenancy at massive scale (millions of topics)
  • You have outgrown Redis Streams (> 10M messages/day with complex routing)

What about Valkey for pub/sub?

Valkey supports pub/sub (SUBSCRIBE, PUBLISH, PSUBSCRIBE) and Streams (XADD, XREAD, XGROUP, XACK) equivalently to Redis 7.2. There is no daylight between Redis and Valkey on pub/sub feature parity. Pick based on the license question, not the pub/sub feature set.

More code samples →Feature comparison →All use cases →