basic_operations/
basic_operations.rs

1use epoch_db::DB;
2use std::path::Path;
3use std::time::Duration;
4
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6    // 1. Open the database. It will be created if it doesn't exist.
7    let db = DB::new(Path::new("./my_database"))?;
8
9    // 2. Set a value with a 10-second TTL.
10    db.set("user:1", "Alice", Some(Duration::from_secs(10)))?;
11
12    // 3. Get the value back.
13    if let Some(value) = db.get("user:1")? {
14        println!("Found value: {}", value); // "Found value: Alice"
15    }
16
17    // 4. Remove the data.
18    db.remove("user:1")?;
19
20    Ok(())
21}