Struct Cluster

Source
pub struct Cluster { /* private fields */ }

Implementations§

Source§

impl Cluster

Source

pub fn new() -> Cluster

Examples found in repository?
examples/cluster.rs (line 7)
6fn test_cluster() -> redis::RedisResult<()> {
7    let mut cluster = redis::Cluster::new();
8    for i in 7000 .. 7001 {
9        try!(cluster.add(&format!("redis://192.168.1.135:{}/", i)[..]));    
10    }
11    let mut cmd = redis::cmd("set");
12    cmd.arg("foo11232").arg(02);
13    try!(cluster.query_cmd(&cmd));
14    let mut cmd = redis::cmd("get");
15    cmd.arg("foo11232");
16    let value : i32 = try!(cluster.query_cmd(&cmd));
17    println!("value = {:?}", value);
18    try!(redis::cmd("set").arg("xxoo1").arg("ooxx").query_cluster(&mut cluster));
19    assert_eq!(redis::cmd("get").arg("xxoo1").query_cluster(&mut cluster), Ok("ooxx".to_string()));
20
21    println!("ok {:?}", 11);
22
23    try!(redis::cmd("SET").arg("key1").arg(b"foo").query_cluster(&mut cluster));
24    println!("1111111111");
25    try!(redis::cmd("SET").arg(&["key5", "bar"]).query_cluster(&mut cluster));
26    println!("222222222");
27    let xx : redis::RedisResult<(String, String)> = redis::cmd("MGET").arg(&["key1", "key1"]).query_cluster(&mut cluster);
28    println!("33333333333 = {:?}", xx);
29
30    let (xx, xx1) : (String, String) = try!(redis::cmd("MGET").arg(&["key1", "key5"]).query_cluster(&mut cluster));
31    println!("xx = {:?}", xx);
32    Ok(())
33}
Source

pub fn add(&mut self, info: &str) -> RedisResult<()>

Examples found in repository?
examples/cluster.rs (line 9)
6fn test_cluster() -> redis::RedisResult<()> {
7    let mut cluster = redis::Cluster::new();
8    for i in 7000 .. 7001 {
9        try!(cluster.add(&format!("redis://192.168.1.135:{}/", i)[..]));    
10    }
11    let mut cmd = redis::cmd("set");
12    cmd.arg("foo11232").arg(02);
13    try!(cluster.query_cmd(&cmd));
14    let mut cmd = redis::cmd("get");
15    cmd.arg("foo11232");
16    let value : i32 = try!(cluster.query_cmd(&cmd));
17    println!("value = {:?}", value);
18    try!(redis::cmd("set").arg("xxoo1").arg("ooxx").query_cluster(&mut cluster));
19    assert_eq!(redis::cmd("get").arg("xxoo1").query_cluster(&mut cluster), Ok("ooxx".to_string()));
20
21    println!("ok {:?}", 11);
22
23    try!(redis::cmd("SET").arg("key1").arg(b"foo").query_cluster(&mut cluster));
24    println!("1111111111");
25    try!(redis::cmd("SET").arg(&["key5", "bar"]).query_cluster(&mut cluster));
26    println!("222222222");
27    let xx : redis::RedisResult<(String, String)> = redis::cmd("MGET").arg(&["key1", "key1"]).query_cluster(&mut cluster);
28    println!("33333333333 = {:?}", xx);
29
30    let (xx, xx1) : (String, String) = try!(redis::cmd("MGET").arg(&["key1", "key5"]).query_cluster(&mut cluster));
31    println!("xx = {:?}", xx);
32    Ok(())
33}
Source

pub fn get_pubsub(&self) -> RedisResult<PubSub>

Returns a PubSub connection. A pubsub connection can be used to listen to messages coming in through the redis publish/subscribe system.

Note that redis’ pubsub operates across all databases.

Source

pub fn get_connection( &mut self, addr: Option<String>, ) -> RedisResult<&Connection>

Source

pub fn get_connection_by_name( &mut self, slot: String, ) -> RedisResult<&Connection>

Source

pub fn get_connection_by_slot(&mut self, slot: u16) -> RedisResult<&Connection>

Source

pub fn query_cmd<T: FromRedisValue>(&mut self, cmd: &Cmd) -> RedisResult<T>

Examples found in repository?
examples/cluster.rs (line 13)
6fn test_cluster() -> redis::RedisResult<()> {
7    let mut cluster = redis::Cluster::new();
8    for i in 7000 .. 7001 {
9        try!(cluster.add(&format!("redis://192.168.1.135:{}/", i)[..]));    
10    }
11    let mut cmd = redis::cmd("set");
12    cmd.arg("foo11232").arg(02);
13    try!(cluster.query_cmd(&cmd));
14    let mut cmd = redis::cmd("get");
15    cmd.arg("foo11232");
16    let value : i32 = try!(cluster.query_cmd(&cmd));
17    println!("value = {:?}", value);
18    try!(redis::cmd("set").arg("xxoo1").arg("ooxx").query_cluster(&mut cluster));
19    assert_eq!(redis::cmd("get").arg("xxoo1").query_cluster(&mut cluster), Ok("ooxx".to_string()));
20
21    println!("ok {:?}", 11);
22
23    try!(redis::cmd("SET").arg("key1").arg(b"foo").query_cluster(&mut cluster));
24    println!("1111111111");
25    try!(redis::cmd("SET").arg(&["key5", "bar"]).query_cluster(&mut cluster));
26    println!("222222222");
27    let xx : redis::RedisResult<(String, String)> = redis::cmd("MGET").arg(&["key1", "key1"]).query_cluster(&mut cluster);
28    println!("33333333333 = {:?}", xx);
29
30    let (xx, xx1) : (String, String) = try!(redis::cmd("MGET").arg(&["key1", "key5"]).query_cluster(&mut cluster));
31    println!("xx = {:?}", xx);
32    Ok(())
33}
Source

pub fn query_pipe<T: FromRedisValue>( &mut self, pipe: &Pipeline, ) -> RedisResult<T>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.