feat(conf): add aof conf

This commit is contained in:
bandl 2021-11-01 23:48:09 +08:00
parent 7aa39979f0
commit 6fc2417de2
3 changed files with 19 additions and 0 deletions

View File

@ -33,6 +33,7 @@ func init() {
func setDefaultConfValue() { func setDefaultConfValue() {
// 设置一些默认值 // 设置一些默认值
viper.SetDefault("version", "base-01") viper.SetDefault("version", "base-01")
defaultStorage()
} }
func LoadConf(path string) error { func LoadConf(path string) error {

11
conf/storage.go Normal file
View File

@ -0,0 +1,11 @@
package conf
import "github.com/spf13/viper"
func defaultStorage() {
// aof
viper.SetDefault("storage.aof-path", "/etc/wheat-cache/wheat.aof")
viper.SetDefault("storage.aof-flush-time", 5)
viper.SetDefault("storage.aof-check-time", 1)
viper.SetDefault("storage.aof-check-freq", 20)
}

View File

@ -6,6 +6,13 @@ storage:
host: '127.0.0.1' host: '127.0.0.1'
port: 5890 port: 5890
timeOut: 2 # second timeOut: 2 # second
aof-codec: "b16" # 目前只实现了 b16 编码方案。
aof-path: "/etc/wheat-cache/wheat.aof"
aof-flush-time: 5 # second , 每 5 秒刷新缓冲区的内容到磁盘。
aof-check-time: 1 # 每 1 second 执行一次 io 检查
aof-check-freq: 20 # 在一个 aof-check-time 周期内,出现超过 aof-check-freq 的 IO 操作会刷新磁盘
# clearSize and maxSize must be Int # clearSize and maxSize must be Int
lruCache: lruCache: