Airomem-rs
Release at crates.io
(Toy) persistence library for Rust inspired by prevayler for java and named after its wrapper airomem.
It is an implementation of the Prevalent System design pattern, in which business objects are kept live in memory and transactions are journaled for system recovery.
Assumptions
- All data lives in memory guarded with
tokio::sync::RwLock, reads are fast and concurrent safe. - By default every transaction is saved to append-only journal file and immediately fsynced.
By that, individual writes are slow, but they SHOULD survive crashes (e.g. power outage, software panic).
However, you can set periodic sync or manual. SeeJournalFlushPolicyfor more info. Recommended for data that may be lost (e.g. cache, http session storage). - I don't guarantee durability, it's created for toy projects or non-relevant data like http authorization tokens/cookies. https://www.postgresql.org/docs/9.4/wal-reliability.html
Features
- - saving executed transactions to append only file
- - split journal log file if too big - while restoring data, all journal logs are loaded at once from disk to maximise throughput (and for simplicity reasons)
- - snapshots for faster recovery
- - stable api
Resources
Example
type UserId = usize;
type SessionsStore = ;
MergeTx!;
async