Skip to content
/ mace Public

An embedded key-value storage engine with ACID support

License

Notifications You must be signed in to change notification settings

abbycin/mace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mace

An embedded key-value storage engine with ACID support. Although it is still under development, you can try it out

use mace::{IsolationLevel, Mace, OpCode, Options};

fn main() -> Result<(), OpCode> {
    let opt = Options::new(std::env::temp_dir().join("mace"));
    let db = Mace::new(opt)?;
    let tx = db.default();

    // start a read-write Txn
    tx.begin(IsolationLevel::SI, |kv| {
        kv.put("foo", "bar")?;
        kv.commit()?;

        let r = kv.get("foo")?;
        assert_eq!(r.data(), "bar".as_bytes());
        Ok(())
    })?;

    // rollback
    tx.begin(IsolationLevel::SI, |kv| {
        kv.put("mo", "ha")?;
        kv.rollback()
    })?;

    // start a read-only Txn
    tx.view(IsolationLevel::SI, |view| {
        let r = view.get("foo")?;
        assert_eq!(r.data(), "bar".as_bytes());
        let r = view.get("mo");
        assert_eq!(r.err().unwrap(), OpCode::NotFound);
        Ok(())
    })
}

About

An embedded key-value storage engine with ACID support

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published