forked from mirror/ledisdb
add dbpath config
This commit is contained in:
parent
39d6db56bd
commit
95cbcc6460
|
@ -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"`
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue