hurrahdb
Hurrahdb is an inmemory key value store with an option of persistance in Rust. Currently only supports AOF option to persist.
Persistance of the data using AOF is async and flushing data into db based on sync_time. Unit of the sync_time in milliseconds.
Usage
While caching/storing a data, key needs to be string type and value needs to be a struct or enum that derives Serialize and Deserialize from serde library. An example model below
use ;
Only In-memory
When a storage is constracted without any config, it will not initilize any persistance logic.
// define a storage object with None
let storage = match new ;
// Cache the `DummyStruct` struct with key "some-key"
match storage.set
// Fetch the `DummyStruct` data using key "some-key"
let result_option: = match storage.get ;
Inmemory With AOF
When a storage is created with AOF config, it reads the input file and precreates the hashmap with the data in the file. In addition to that creates a background job to flush data into disk based on sync_time value.
Note:
- Since the data flushing async, it does not grantee the persistance. You might loss your data during shotdown/crash states of the app.
- Requires
tokio run time
Example usage here
// Define a storage with AOF config. Flushes data into file every 100ms.
let storage = match new ;
// Cache the `DummyStruct` struct with key "some-key"
match storage.set
// Fetch the `DummyStruct` data using key "some-key"
let result_option: = match storage.get ;