add 磁盘缓存,前置路由,代码生成模板完善

This commit is contained in:
yxh
2024-01-29 14:52:41 +08:00
parent 64fa125cf1
commit b1a6944cbc
25 changed files with 314 additions and 41 deletions

View File

@@ -10,6 +10,7 @@ package consts
const (
CacheModelMem = "memory"
CacheModelRedis = "redis"
CacheModelDist = "dist"
// CacheSysDict 字典缓存菜单KEY
CacheSysDict = "sysDict"

View File

@@ -10,6 +10,7 @@ package cache
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"github.com/tiger1103/gfast-cache/adapter"
"github.com/tiger1103/gfast-cache/cache"
"github.com/tiger1103/gfast/v3/internal/app/common/consts"
"github.com/tiger1103/gfast/v3/internal/app/common/service"
@@ -26,9 +27,14 @@ func New() service.ICache {
)
prefix := g.Cfg().MustGet(ctx, "system.cache.prefix").String()
model := g.Cfg().MustGet(ctx, "system.cache.model").String()
distPath := g.Cfg().MustGet(ctx, "system.cache.distPath").String()
if model == consts.CacheModelRedis {
// redis
cacheContainer = cache.NewRedis(prefix)
} else if model == consts.CacheModelDist {
// dist
adapter.SetConfig(&adapter.Config{Dir: distPath})
cacheContainer = cache.NewDist(prefix)
} else {
// memory
cacheContainer = cache.New(prefix)

View File

@@ -29,4 +29,6 @@ type TokenOptions struct {
// 拦截排除地址
ExcludePaths g.SliceStr `json:"excludePaths"`
CacheModel string `json:"cacheModel"`
//磁盘缓存路径
DistPath string `json:"distPath"`
}