Struct redis::PubSub[][src]

pub struct PubSub<'a> { /* fields omitted */ }

Represents a pubsub connection.

Methods

impl<'a> PubSub<'a>
[src]

The pubsub object provides convenient access to the redis pubsub system. Once created you can subscribe and unsubscribe from channels and listen in on messages.

Example:

let client = try!(redis::Client::open("redis://127.0.0.1/"));
let mut con = client.get_connection()?;
let mut pubsub = con.as_pubsub();
try!(pubsub.subscribe("channel_1"));
try!(pubsub.subscribe("channel_2"));

loop {
    let msg = try!(pubsub.get_message());
    let payload : String = try!(msg.get_payload());
    println!("channel '{}': {}", msg.get_channel_name(), payload);
}

Subscribes to a new channel.

Subscribes to a new channel with a pattern.

Unsubscribes from a channel.

Unsubscribes from a channel with a pattern.

Fetches the next message from the pubsub connection. Blocks until a message becomes available. This currently does not provide a wait not to block :(

The message itself is still generic and can be converted into an appropriate type through the helper methods on it.

Sets the read timeout for the connection.

If the provided value is None, then get_message call will block indefinitely. It is an error to pass the zero Duration to this method.

Trait Implementations

impl<'a> Drop for PubSub<'a>
[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<'a> Send for PubSub<'a>

impl<'a> !Sync for PubSub<'a>