#stack #readonly-history

bin+lib stack-db

A (basically) infinitely stacking & extendable CoW database that has both readonly safety and incredible write speeds at the same time

3 releases

0.3.5 Sep 23, 2024
0.3.4 Sep 23, 2024
0.3.3 Aug 11, 2024
0.3.2 Mar 7, 2024
0.1.0 Mar 3, 2024

#687 in Database interfaces

Download history 39/week @ 2024-07-01 68/week @ 2024-08-05 51/week @ 2024-08-12 4/week @ 2024-08-26 15/week @ 2024-09-16 312/week @ 2024-09-23 50/week @ 2024-09-30 17/week @ 2024-10-07

394 downloads per month
Used in thoughts

MIT/Apache

29KB
506 lines

stack-db

A (basically) infinitely stacking & extendable CoW database that has both readonly safety and incredible write speeds at the same time.

Examples


Example of a basic in-memory binary database

Here is a basic in-memory database that only deals with binary indexes and data (that uses the allocators provided by the library)

use stack_db::prelude::*;

let allocator = SkdbMemAlloc; // or `SkdbDiskAlloc::new()`
let mut database = StackDB::new(allocator).unwrap();

// writing
database.write(256, b"hello, ").unwrap();
database.write(256+7, b"world").unwrap();

// reading
assert_eq!(&*database.read(256..268).unwrap(), b"hello, world");

// flush to save all changes
database.flush().unwrap();

// over-writting
database.write(256, b"H").unwrap();
database.write(256+7, b"W").unwrap();
database.write(268, b"!").unwrap();

// flush again
database.flush().unwrap();

// reading
assert_eq!(&*database.read(256..269).unwrap(), b"Hello, World!");

// rebase to save space
database.rebase(256).unwrap(); // rebase with a 256 byte buffer

No runtime deps