forked from ApolloCrawler/gauc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello_world.rs
30 lines (24 loc) · 893 Bytes
/
hello_world.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
extern crate gauc;
extern crate env_logger;
use gauc::client::*;
fn main() {
env_logger::init().unwrap();
const NUM_ITERATIONS: i32 = 100;
if let Ok(mut client) = Client::connect("couchbase://localhost/default", None) {
for i in 0..NUM_ITERATIONS {
println!("Iteration #{}", i);
// Store some data
client.upsert(&format!("foo{}", i), &format!("{{\"msg\": \"This is test No. {}!\"}}", i), 0, 0, |res| {
if let Ok(response) = res {
println!("Created new document, CAS: {}", response.cas)
}
});
// Get data
client.get(&format!("foo{}", i), |res| {
if let Ok(response) = res {
println!("Got response: {} - {}", response.key.unwrap(), response.value.unwrap())
}
});
}
}
}