Redis®*: Advanced Redis Pub/Sub examples with Python

This documentation is part of the Using with Python guide. You can view the complete guide here: How to connect Redis with Python.

👋 Welcome to the Stackhero documentation!

Stackhero offers a ready-to-use Redis cloud solution that provides a host of benefits, including:

  • Redis Commander web UI included.
  • Unlimited message size and transfers.
  • Effortless updates with just a click.
  • Optimal performance and robust security powered by a private and dedicated VM.

Save time and simplify your life: it only takes 5 minutes to try Stackhero's Redis cloud hosting solution!

You might want to explore more advanced Pub/Sub techniques with the following examples:

# Create a PubSub instance and ignore subscribe messages
p = r.pubsub(ignore_subscribe_messages=True)

# Subscribe to multiple channels
p.subscribe('test-1', 'test-2', ...)

# Unsubscribe from multiple channels
p.unsubscribe('test-1', 'test-2', ...)

# You can also use "unsubscribe" with no arguments to disconnect from all subscribed channels
p.unsubscribe()

# Subscribe to channels using a pattern
p.psubscribe('my-*')

# Unsubscribe from channels using a pattern
p.punsubscribe('my-*')