basteh-redb

Crates.iobasteh-redb
lib.rsbasteh-redb
version0.4.0-alpha.6
sourcesrc
created_at2023-02-06 16:33:57.153333
updated_at2023-08-09 13:31:43.863343
descriptionAn implementation of basteh based on redb
homepage
repositoryhttps://github.com/pooyamb/basteh/
max_upload_size
id778004
size67,671
Pouya Mobasher Behrouz (pooyamb)

documentation

https://docs.rs/basteh-redb

README

basteh-redb

This crate provides implementations for basteh based on redb database.

Please refer to basteh crate documentations for full details about usage and use cases.

Implementation details

RedbBackend will spawn tasks on tokio's threadpool.

It is possible to specify the number of instances being used in thread-pool.

use basteh_sled::{RedbBackend, Database};

// Refer to redb's documentation for more options
let redb_db = Database::create("test.db").unwrap();

// Open the database and make a store(not started yet)
let store = RedbBackend::from_db(redb_db);

let store = store
            // If you want to scan the database on start for expiration
            .scan_db_on_start(true)
            // If you want the expiration thread to perform deletion instead of soft deleting items
            .perform_deletion(true)
            // Finally start the tasks
            .start(4); // Number of threads

Impl notes

Each scope has its own table with the same as scope. Expiration flags are stored inside the database and in a seperate table for each scope. We also use a priority-queue to get notifications about expirations if perform_deletion is true. If scan_db_on_start is set, the database will be scanned to find expired items, which may cause loss of data if system's time have changed.

Commit count: 192

cargo fmt