1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::{fs, thread};
use std::path::{PathBuf};
use std::time::Duration;
use df_cache::Cache;
fn main() {
let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let dir = dir.join("config");
let config_path = dir.join("cache.json");
let conf = fs::read_to_string(config_path.to_str().unwrap()).unwrap();
let conf = json::parse(conf.as_str().clone()).unwrap();
let mut cache = Cache::connect(conf);
let data = cache.db(0).set("t", "1".into(), 2);
println!(">>>{}", data);
thread::sleep(Duration::from_secs(1));
let data = cache.db(0).get("t");
println!(">>>{}", data);
}