1 个稳定版本
1.0.10 | 2021年4月29日 |
---|---|
1.0.8 |
|
1.0.6 |
|
1.0.2 |
|
0.1.8 |
|
#1115 在 数据库接口 中
每月32次下载数
14KB
137 行
内存序列化到磁盘的数据库。模仿FifthDatabase(C++ / boost),SixthDatabase是为Rust使用Serde设计的。
要求
[dependencies]
sixth_database = "*"
用法
// more examples at https://gitlab.com/Wepwawet/sixthdatabase/-/tree/master/examples
extern crate sixth_database;
use sixth_database::Database;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
// this example is intended to be ran multiple times, each time it is ran
// an entry is saved into the database and re-loaded when the program starts again
fn main() {
let example: Arc<Mutex<Database<String>>> = Database::new("example_db_name");
// let example = Database::new("example_db_name"); // also acceptable
{
let mut test = example.lock().expect("Failed to obtain 6db lock");
test.data.push("testing 123".to_string());
for datum in &test.data {
println!("{}", datum);
}
// after the program has been ran 10 times, the 'database' will contain 10 entires. this then clears the contents of the vector, and database
if test.data.len() > 10
{
test.data.clear();
}
std::mem::drop(test);
}
// if the program terminates immediately in main, threads appear to exit too quickly to save data
thread::sleep(Duration::from_secs(1));
}
获取帮助
在 https://gitlab.com/Wepwawet/sixthdatabase/issues/new 上提交一个工单
如果你使用了这个项目并希望你的项目在这里展示,请提交一个工单。
依赖
~0.6–1.2MB
~29K SLoC