增加缓存qps

This commit is contained in:
ayflying
2025-04-02 11:32:54 +08:00
parent 5e18d67747
commit db3a2bf405
4 changed files with 56 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
package aycache
import (
"github.com/ayflying/utility_go/pkg/aycache/drive"
"github.com/ayflying/utility_go/pkg"
"github.com/gogf/gf/v2/os/gcache"
)
@@ -11,24 +11,5 @@ type Mod struct {
// Deprecated:弃用,改用 pkg.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 = drive.NewAdapterMemory()
case "redis":
cacheAdapterObj = drive.NewAdapterRedis()
case "file":
cacheAdapterObj = drive.NewAdapterFile("runtime/cache")
//case "es":
//cacheAdapterObj = drive.NewAdapterElasticsearch("http://127.0.0.1:9200"})
}
//var client = gcache.New()
//client.SetAdapter(cacheAdapterObj)
return cacheAdapterObj
return pkg.Cache(_name...)
}