mirror of
https://github.com/tiger1103/gfast.git
synced 2026-10-01 05:07:04 +00:00
43 lines
777 B
Go
43 lines
777 B
Go
/*
|
|
* @desc:缓存处理
|
|
* @company:云南奇讯科技有限公司
|
|
* @Author: yixiaohu
|
|
* @Date: 2022/3/9 11:15
|
|
*/
|
|
|
|
package service
|
|
|
|
import (
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/os/gctx"
|
|
"github.com/tiger1103/gfast-cache/cache"
|
|
"github.com/tiger1103/gfast/v3/internal/app/common/consts"
|
|
)
|
|
|
|
type ICache interface {
|
|
cache.IGCache
|
|
}
|
|
|
|
type cacheImpl struct {
|
|
*cache.GfCache
|
|
prefix string
|
|
}
|
|
|
|
var c = cacheImpl{}
|
|
|
|
func Cache() ICache {
|
|
var (
|
|
ch = c
|
|
ctx = gctx.New()
|
|
)
|
|
prefix := g.Cfg().MustGet(ctx, "system.cache.prefix").String()
|
|
model := g.Cfg().MustGet(ctx, "system.cache.model").String()
|
|
if model == consts.CacheModelRedis {
|
|
// redis
|
|
ch.GfCache = cache.NewRedis(prefix)
|
|
} else {
|
|
ch.GfCache = cache.New(prefix)
|
|
}
|
|
return ICache(&ch)
|
|
}
|