3个版本

0.4.0-alpha.62023年8月9日
0.4.0-alpha.52023年3月6日
0.4.0-alpha.42023年2月6日

#1185 in HTTP服务器

MIT/Apache

115KB
2.5K SLoC

basteh-redb

此crate提供了基于redb数据库的basteh实现。

有关使用和用例的完整详细信息,请参阅basteh crate文档。

实现细节

RedbBackend将在tokio的线程池中启动任务。

可以指定在线程池中使用的实例数量。

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

实现说明

每个作用域都有自己的表,其结构与作用域相同。过期标志存储在数据库中,并为每个作用域单独存储一个表。我们还在perform_deletion为true的情况下使用优先级队列来获取有关过期的通知。如果scan_db_on_start被设置,数据库将被扫描以查找过期的项,如果系统时间已更改,这可能会导致数据丢失。

依赖关系

~5–12MB
~118K SLoC