Struct td_rredis::PubSub
[−]
[src]
pub struct PubSub { /* fields omitted */ }
Represents a pubsub connection.
Methods
impl PubSub
[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!(td_rredis::Client::open("redis://127.0.0.1/")); let mut pubsub = try!(client.get_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); }
fn subscribe(&mut self, channel: String) -> RedisResult<()>
Subscribes to a new channel.
fn subscribes(&mut self, channels: Vec<String>) -> RedisResult<()>
fn psubscribe(&mut self, channel: String) -> RedisResult<()>
Subscribes to a new channel with a pattern.
fn psubscribes(&mut self, channels: Vec<String>) -> RedisResult<()>
Subscribes to a new channel with a pattern.
fn unsubscribe(&mut self, channel: String) -> RedisResult<()>
Unsubscribes from a channel.
fn unsubscribes(&mut self, channels: Vec<String>) -> RedisResult<()>
Unsubscribes from a channel.
fn punsubscribe(&mut self, channel: String) -> RedisResult<()>
Unsubscribes from a channel.
fn punsubscribes(&mut self, channels: Vec<String>) -> RedisResult<()>
Unsubscribes from a channel.
fn try_clone(&self) -> RedisResult<PubSub>
fn is_work(&self) -> bool
fn get_connection_fd(&self) -> i32
fn get_message(&self) -> RedisResult<Msg>
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.