add 磁盘缓存,前置路由,代码生成模板完善
This commit is contained in:
@@ -10,6 +10,7 @@ package consts
|
||||
const (
|
||||
CacheModelMem = "memory"
|
||||
CacheModelRedis = "redis"
|
||||
CacheModelDist = "dist"
|
||||
|
||||
// CacheSysDict 字典缓存菜单KEY
|
||||
CacheSysDict = "sysDict"
|
||||
|
6
internal/app/common/logic/cache/cache.go
vendored
6
internal/app/common/logic/cache/cache.go
vendored
@@ -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)
|
||||
|
@@ -29,4 +29,6 @@ type TokenOptions struct {
|
||||
// 拦截排除地址
|
||||
ExcludePaths g.SliceStr `json:"excludePaths"`
|
||||
CacheModel string `json:"cacheModel"`
|
||||
//磁盘缓存路径
|
||||
DistPath string `json:"distPath"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user