test/
test.rs

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