使用统一方法pgk进行调用

This commit is contained in:
ayflying
2025-03-04 18:58:10 +08:00
parent 6eeb5a57cd
commit 0e55698a47
24 changed files with 1452 additions and 112 deletions

38
pgk/aycache/cache.go Normal file
View File

@@ -0,0 +1,38 @@
package aycache
import (
"github.com/ayflying/utility_go/package/aycache/drive"
drive2 "github.com/ayflying/utility_go/pgk/aycache/drive"
"github.com/gogf/gf/v2/os/gcache"
)
type Mod struct {
client *gcache.Cache
}
//func NewV1(_name ...string) *cache.Mod {
// return pgk.Cache
//}
func New(_name ...string) gcache.Adapter {
var cacheAdapterObj gcache.Adapter
var name = "cache"
if len(_name) > 0 {
name = _name[0]
}
switch name {
case "cache":
cacheAdapterObj = drive2.NewAdapterMemory()
case "redis":
cacheAdapterObj = drive2.NewAdapterRedis()
case "file":
cacheAdapterObj = drive2.NewAdapterFile("runtime/cache")
case "es":
cacheAdapterObj = drive.NewAdapterElasticsearch([]string{"http://127.0.0.1:9200"})
}
//var client = gcache.New()
//client.SetAdapter(cacheAdapterObj)
return cacheAdapterObj
}