优化全局变量
This commit is contained in:
Vendored
+6
-6
@@ -1,22 +1,22 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"cutego/modules"
|
||||
"cutego/pkg/common"
|
||||
"cutego/pkg/constant"
|
||||
"cutego/refs"
|
||||
)
|
||||
|
||||
// RemoveList 批量根据Key删除数据
|
||||
// @Param list []string 键合集
|
||||
func RemoveList(list []string) {
|
||||
modules.RedisDB.DELALL(list)
|
||||
refs.RedisDB.DELALL(list)
|
||||
}
|
||||
|
||||
// RemoveKey 根据key删除
|
||||
// @Param key 键
|
||||
// @Return int 删除的数量
|
||||
func RemoveCache(key string) int {
|
||||
del, err := modules.RedisDB.DEL(key)
|
||||
del, err := refs.RedisDB.DEL(key)
|
||||
if err != nil {
|
||||
common.ErrorLog(err)
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func RemoveCache(key string) int {
|
||||
// @Param key 键
|
||||
// @Return string 值
|
||||
func GetCache(key string) string {
|
||||
val, err := modules.RedisDB.GET(key)
|
||||
val, err := refs.RedisDB.GET(key)
|
||||
if err != nil {
|
||||
common.ErrorLog(constant.RedisConst{}.GetRedisError(), err.Error())
|
||||
return ""
|
||||
@@ -40,7 +40,7 @@ func GetCache(key string) string {
|
||||
// @Param value 值
|
||||
// @Return 新增的行数
|
||||
func SetCache(key string, value interface{}) int {
|
||||
n, err := modules.RedisDB.SET(key, common.StructToJson(value))
|
||||
n, err := refs.RedisDB.SET(key, common.StructToJson(value))
|
||||
if err != nil {
|
||||
common.ErrorLog(constant.RedisConst{}.GetRedisError(), err.Error())
|
||||
return 0
|
||||
@@ -54,5 +54,5 @@ func SetCache(key string, value interface{}) int {
|
||||
// @Param sec 过期时间(单位: 秒)
|
||||
// @Return 新增的行数
|
||||
func SetCacheTTL(key string, value interface{}, sec int) {
|
||||
modules.RedisDB.SETEX(key, sec, common.StructToJson(value))
|
||||
refs.RedisDB.SETEX(key, sec, common.StructToJson(value))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user