Memcached library in Rust
extern crate memcached;
use std::collections::TreeMap;
use memcached::Client;
use memcached::proto::{Operation, MultiOperation, NoReplyOperation, CasOperation, ProtoType};
fn main() {
let servers = [
("tcp://127.0.0.1:11211", 1),
];
let mut client = Client::connect(&servers, ProtoType::Binary).unwrap();
client.set(b"Foo", b"Bar", 0xdeadbeef, 2).unwrap();
let (value, flags) = client.get(b"Foo").unwrap();
assert_eq!(value.as_slice(), b"Bar");
assert_eq!(flags, 0xdeadbeef);
client.set_noreply(b"key:dontreply", b"1", 0x00000001, 20).unwrap();
let (_, cas_val) = client.increment_cas(b"key:numerical", 10, 1, 20, 0).unwrap();
client.increment_cas(b"key:numerical", 1, 1, 20, cas_val).unwrap();
}
Run cargo doc --open
for more details.
- Auto-disable failed servers
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.