pub struct ClusterCmd { /* private fields */ }
Expand description
Redis::Cmd’s args
field is private,
but we need it to determine a slot from the command.
So this is a simple wrapper around Redis::Cmd that keeps
track of the args.
Implementations§
Source§impl ClusterCmd
impl ClusterCmd
Sourcepub fn new() -> ClusterCmd
pub fn new() -> ClusterCmd
Examples found in repository?
examples/basic.rs (line 11)
7fn main() {
8 let startup_nodes =
9 vec!["redis://127.0.0.1:7000", "redis://127.0.0.1:7001", "redis://127.0.0.1:7002"];
10 let mut clus = Cluster::new(startup_nodes);
11 let mut cmd = ClusterCmd::new();
12 cmd.arg("SET").arg("foo").arg("bar");
13 let _: () = clus.send_command(&cmd).unwrap();
14
15 let mut cmd = ClusterCmd::new();
16 cmd.arg("GET").arg("foo");
17 let res: String = clus.send_command(&cmd).unwrap();
18 println!("{:?}", res);
19 assert_eq!(res, "bar");
20
21 let _: () = clus.set("hey", "there").unwrap();
22 let res: String = clus.get("hey").unwrap();
23 println!("{:?}", res);
24 assert_eq!(res, "there");
25}
Sourcepub fn arg<T: ToRedisArgs>(&mut self, arg: T) -> &mut ClusterCmd
pub fn arg<T: ToRedisArgs>(&mut self, arg: T) -> &mut ClusterCmd
Add an arg to the command.
Examples found in repository?
examples/basic.rs (line 12)
7fn main() {
8 let startup_nodes =
9 vec!["redis://127.0.0.1:7000", "redis://127.0.0.1:7001", "redis://127.0.0.1:7002"];
10 let mut clus = Cluster::new(startup_nodes);
11 let mut cmd = ClusterCmd::new();
12 cmd.arg("SET").arg("foo").arg("bar");
13 let _: () = clus.send_command(&cmd).unwrap();
14
15 let mut cmd = ClusterCmd::new();
16 cmd.arg("GET").arg("foo");
17 let res: String = clus.send_command(&cmd).unwrap();
18 println!("{:?}", res);
19 assert_eq!(res, "bar");
20
21 let _: () = clus.set("hey", "there").unwrap();
22 let res: String = clus.get("hey").unwrap();
23 println!("{:?}", res);
24 assert_eq!(res, "there");
25}
Sourcepub fn query<T: FromRedisValue>(&self, conn: &Connection) -> RedisResult<T>
pub fn query<T: FromRedisValue>(&self, conn: &Connection) -> RedisResult<T>
Execute the command, returning the result.
Auto Trait Implementations§
impl Freeze for ClusterCmd
impl RefUnwindSafe for ClusterCmd
impl Send for ClusterCmd
impl Sync for ClusterCmd
impl Unpin for ClusterCmd
impl UnwindSafe for ClusterCmd
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more