Crates.io | basteh-redb |
lib.rs | basteh-redb |
version | 0.4.0-alpha.6 |
source | src |
created_at | 2023-02-06 16:33:57.153333 |
updated_at | 2023-08-09 13:31:43.863343 |
description | An implementation of basteh based on redb |
homepage | |
repository | https://github.com/pooyamb/basteh/ |
max_upload_size | |
id | 778004 |
size | 67,671 |
This crate provides implementations for basteh based on redb
database.
Please refer to basteh crate documentations for full details about usage and use cases.
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
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.