Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spacejam/acid-state
rust transactional state library
https://github.com/spacejam/acid-state
high-performance persistence rust transactional
Last synced: about 2 months ago
JSON representation
rust transactional state library
- Host: GitHub
- URL: https://github.com/spacejam/acid-state
- Owner: spacejam
- Created: 2017-02-01T01:47:48.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-05T08:31:03.000Z (about 6 years ago)
- Last Synced: 2024-10-29T17:31:22.573Z (2 months ago)
- Topics: high-performance, persistence, rust, transactional
- Language: Rust
- Size: 6.84 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# acid-state
rust transactional state librarynote: not atomic yet, coming soon
currently suitable for rapid prototyping of simple stateful systems
note: every op is O(n), so treat this as a poor man's DB for prototyping
```rust
#[macro_use]
extern crate acid_state;
#[macro_use]
extern crate lazy_static;
extern crate rustc_serialize;use std::collections::HashMap;
#[derive(Debug, RustcDecodable, RustcEncodable)]
struct Cs {
v: u64,
}acid_state! {
A: HashMap = HashMap::new();
B: u64 = 0;
C: Cs = Cs {
v: 0
};
}fn main() {
let key = "yo".to_owned();
acid! {
(A => a, B => b, C => c) => {
// A, B, C have been pulled off disk
let mut current = a.entry(key).or_insert(0);
**b += 1;
*current += 1;
c.v += 1;
println!("a is now {:?}", current);
println!("b is now {:?}", **b);
println!("c is now {:?}", c.v);
// new values of A, B, C are now synced on disk
}
};
}
```