增加获取缓存实例的方法

This commit is contained in:
白茶清欢 2024-06-21 14:58:49 +08:00
parent 4b82877f85
commit 225a1ae9b2
3 changed files with 32 additions and 1 deletions

29
common.go Normal file
View File

@ -0,0 +1,29 @@
// Package cache ...
//
// Description : cache ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2024-06-21 14:55
package cache
import (
cacheAbstract "git.zhangdeman.cn/zhangdeman/cache/abstract"
"git.zhangdeman.cn/zhangdeman/consts"
"strings"
)
// GetCacheInstance 获取缓存实例
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:56 2024/6/21
func GetCacheInstance(cacheDriver string) cacheAbstract.ICache {
switch strings.ToLower(cacheDriver) {
case consts.CacheDriverRedis:
return RedisClient
case consts.CacheDriverGocache:
return GocacheClient
}
return nil
}

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.22.4
require git.zhangdeman.cn/zhangdeman/redis v0.0.0-20240621044326-9daae920468f
require (
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240617073616-39e82fd033ed // indirect
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240621065139-666060e4de0b // indirect
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211 // indirect
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0 // indirect
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240618035451-8d48a6bd39dd // indirect

2
go.sum
View File

@ -1,5 +1,7 @@
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240617073616-39e82fd033ed h1:BGv+y6ZdtkxI4HeSIHun0QRrIzjLnUht0bKdyO2t6n4=
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240617073616-39e82fd033ed/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240621065139-666060e4de0b h1:9rQAR9naSQL5DCdjIW0lZwzs+a4R5lW/NYJ4Ng3hqic=
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240621065139-666060e4de0b/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211 h1:I/wOsRpCSRkU9vo1u703slQsmK0wnNeZzsWQOGtIAG0=
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211/go.mod h1:SrtvrQRdzt+8KfYzvosH++gWxo2ShPTzR1m3VQ6uX7U=
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0 h1:gUDlQMuJ4xNfP2Abl1Msmpa3fASLWYkNlqDFF/6GN0Y=