mirror of
https://github.com/davegallant/rfd-notify.git
synced 2025-08-09 18:02:28 +00:00
Add optional --dbpath flag (#6)
* Use common config with lower cache capacity * Add command line argument parser * Add optional --dbpath flag
This commit is contained in:
15
src/db.rs
15
src/db.rs
@@ -1,5 +1,12 @@
|
||||
pub fn hash_exists(hash: &str) -> bool {
|
||||
let tree = sled::open("./deals_db").expect("open");
|
||||
pub fn get_config(dbpath: &str) -> sled::Config {
|
||||
sled::Config::default()
|
||||
.path(dbpath)
|
||||
.cache_capacity(100_000_000)
|
||||
.flush_every_ms(Some(1000))
|
||||
}
|
||||
|
||||
pub fn hash_exists(hash: &str, config: sled::Config) -> bool {
|
||||
let tree = config.open().unwrap();
|
||||
let result = tree.get(hash);
|
||||
if result.is_err() {
|
||||
error!("{:?}", &result);
|
||||
@@ -10,8 +17,8 @@ pub fn hash_exists(hash: &str) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn insert(hash: &str) {
|
||||
let tree = sled::open("./deals_db").expect("open");
|
||||
pub fn insert(hash: &str, config: sled::Config) {
|
||||
let tree = config.open().unwrap();
|
||||
let result = tree.insert(&hash, "");
|
||||
if result.is_err() {
|
||||
error!("{:?}", &result);
|
||||
|
Reference in New Issue
Block a user