mirror of https://github.com/ledisdb/ledisdb.git
add dbpath config
This commit is contained in:
parent
39d6db56bd
commit
95cbcc6460
|
@ -50,6 +50,7 @@ type Config struct {
|
||||||
DataDir string `toml:"data_dir"`
|
DataDir string `toml:"data_dir"`
|
||||||
|
|
||||||
DBName string `toml:"db_name"`
|
DBName string `toml:"db_name"`
|
||||||
|
DBPath string `toml:"db_path"`
|
||||||
|
|
||||||
LevelDB LevelDBConfig `toml:"leveldb"`
|
LevelDB LevelDBConfig `toml:"leveldb"`
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ slaveof = ""
|
||||||
#
|
#
|
||||||
db_name = "leveldb"
|
db_name = "leveldb"
|
||||||
|
|
||||||
|
# if not set, use data_dir/"db_name"_data
|
||||||
|
db_path = ""
|
||||||
|
|
||||||
[leveldb]
|
[leveldb]
|
||||||
compression = false
|
compression = false
|
||||||
block_size = 32768
|
block_size = 32768
|
||||||
|
|
|
@ -29,6 +29,9 @@ slaveof = ""
|
||||||
#
|
#
|
||||||
db_name = "leveldb"
|
db_name = "leveldb"
|
||||||
|
|
||||||
|
# if not set, use data_dir/"db_name"_data
|
||||||
|
db_path = ""
|
||||||
|
|
||||||
[leveldb]
|
[leveldb]
|
||||||
compression = false
|
compression = false
|
||||||
block_size = 32768
|
block_size = 32768
|
||||||
|
|
|
@ -16,7 +16,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func getStorePath(cfg *config.Config) string {
|
func getStorePath(cfg *config.Config) string {
|
||||||
|
if len(cfg.DBPath) > 0 {
|
||||||
|
return cfg.DBPath
|
||||||
|
} else {
|
||||||
return path.Join(cfg.DataDir, fmt.Sprintf("%s_data", cfg.DBName))
|
return path.Join(cfg.DataDir, fmt.Sprintf("%s_data", cfg.DBName))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Open(cfg *config.Config) (*DB, error) {
|
func Open(cfg *config.Config) (*DB, error) {
|
||||||
|
|
Loading…
Reference in New Issue