From 6fc2417de2792b9a7b856b1479dd32e98335deee Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Mon, 1 Nov 2021 23:48:09 +0800 Subject: [PATCH] feat(conf): add aof conf --- conf/public_conf.go | 1 + conf/storage.go | 11 +++++++++++ conf/wheat-cache.yaml | 7 +++++++ 3 files changed, 19 insertions(+) create mode 100644 conf/storage.go diff --git a/conf/public_conf.go b/conf/public_conf.go index d5f0791..9ce786b 100644 --- a/conf/public_conf.go +++ b/conf/public_conf.go @@ -33,6 +33,7 @@ func init() { func setDefaultConfValue() { // 设置一些默认值 viper.SetDefault("version", "base-01") + defaultStorage() } func LoadConf(path string) error { diff --git a/conf/storage.go b/conf/storage.go new file mode 100644 index 0000000..af0f30a --- /dev/null +++ b/conf/storage.go @@ -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) +} diff --git a/conf/wheat-cache.yaml b/conf/wheat-cache.yaml index 9d89429..51687c3 100644 --- a/conf/wheat-cache.yaml +++ b/conf/wheat-cache.yaml @@ -6,6 +6,13 @@ storage: host: '127.0.0.1' port: 5890 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 lruCache: