diff --git a/config/config.go b/config/config.go index ca93d29..1464edf 100644 --- a/config/config.go +++ b/config/config.go @@ -50,6 +50,7 @@ type Config struct { DataDir string `toml:"data_dir"` DBName string `toml:"db_name"` + DBPath string `toml:"db_path"` LevelDB LevelDBConfig `toml:"leveldb"` diff --git a/config/config.toml b/config/config.toml index 2a3a246..f271a70 100644 --- a/config/config.toml +++ b/config/config.toml @@ -27,6 +27,9 @@ slaveof = "" # db_name = "leveldb" +# if not set, use data_dir/"db_name"_data +db_path = "" + [leveldb] compression = false block_size = 32768 diff --git a/etc/ledis.conf b/etc/ledis.conf index d3adbd8..c0606eb 100644 --- a/etc/ledis.conf +++ b/etc/ledis.conf @@ -29,6 +29,9 @@ slaveof = "" # db_name = "leveldb" +# if not set, use data_dir/"db_name"_data +db_path = "" + [leveldb] compression = false block_size = 32768 diff --git a/store/store.go b/store/store.go index aa4b485..2edde30 100644 --- a/store/store.go +++ b/store/store.go @@ -16,7 +16,11 @@ import ( ) func getStorePath(cfg *config.Config) string { - return path.Join(cfg.DataDir, fmt.Sprintf("%s_data", cfg.DBName)) + if len(cfg.DBPath) > 0 { + return cfg.DBPath + } else { + return path.Join(cfg.DataDir, fmt.Sprintf("%s_data", cfg.DBName)) + } } func Open(cfg *config.Config) (*DB, error) {