支持存储配置到 redis

This commit is contained in:
dragon
2025-07-23 11:24:47 +08:00
parent 12eb21a5cd
commit 1e0fa15c42
7 changed files with 202 additions and 106 deletions

View File

@@ -4,7 +4,6 @@ import (
_ "embed"
"net/http"
"os"
"path/filepath"
"text/template"
"time"
@@ -86,16 +85,11 @@ func (c *Config) NewPageServerOptions() (*pkg.ServerOptions, error) {
DefaultErrorHandler: c.ErrorHandler,
Cache: utils.NewCacheMemory(int(cacheMaxSize), int(cacheMaxSize)),
}
if c.Cache.Storage != "" {
if err := os.MkdirAll(filepath.Dir(c.Cache.Storage), 0o755); err != nil && !os.IsExist(err) {
return nil, err
}
}
memory, err := utils.NewConfigMemory(c.Cache.Storage)
cfg, err := utils.NewAutoConfig(c.Cache.Storage)
if err != nil {
return nil, errors.Wrapf(err, "failed to init config memory")
}
rel.KVConfig = memory
rel.KVConfig = cfg
return &rel, nil
}