Add rocksdb

This commit is contained in:
2025-10-26 00:28:24 +08:00
parent 5c466d37e9
commit 9f6c81471e
15 changed files with 424 additions and 266 deletions

View File

@@ -1,7 +1,7 @@
use directories::BaseDirs;
use lazy_static::lazy_static;
use std::path::PathBuf;
use crate::config::types::ApplicationConfig;
use crate::models::{DLSiteManiax, RocksColumn};
const APP_DIR_NAME: &str = "sus_manager";
lazy_static! {
@@ -11,4 +11,27 @@ lazy_static! {
pub static ref APP_DATA_DIR: PathBuf = BASE_DIRS.data_dir().to_path_buf().join(APP_DIR_NAME);
pub static ref APP_CACHE_PATH: PathBuf = BASE_DIRS.cache_dir().to_path_buf().join(APP_DIR_NAME);
pub static ref APP_CONIFG_FILE_PATH: PathBuf = APP_CONFIG_DIR.clone().join("config.json");
pub static ref APP_DB_DATA_DIR: PathBuf = APP_DATA_DIR.clone().join("db");
pub static ref DB_OPTIONS: rocksdb::Options = get_db_options();
pub static ref DB_CF_OPTIONS: rocksdb::Options = get_cf_options();
}
lazy_static! {
pub static ref DB_COLUMNS: Vec<String> = vec![DLSiteManiax::get_column_name().to_string()];
}
fn get_db_options() -> rocksdb::Options {
let mut opts = rocksdb::Options::default();
opts.create_missing_column_families(true);
opts.create_if_missing(true);
opts
}
fn get_cf_options() -> rocksdb::Options {
let opts = rocksdb::Options::default();
opts
}