https://github.com/kalscium/stack-db
A (basically) infinitely stacking & extendable CoW database that has both readonly safety and incredible write speeds at the same time.
https://github.com/kalscium/stack-db
database framework rust
Last synced: 4 months ago
JSON representation
A (basically) infinitely stacking & extendable CoW database that has both readonly safety and incredible write speeds at the same time.
- Host: GitHub
- URL: https://github.com/kalscium/stack-db
- Owner: kalscium
- License: apache-2.0
- Created: 2024-01-30T01:26:25.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-23T11:47:02.000Z (over 1 year ago)
- Last Synced: 2025-12-05T03:43:06.511Z (4 months ago)
- Topics: database, framework, rust
- Language: Rust
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# 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)
```rust
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
```