删除common/consts包 - 将Redis Key常量迁移到redis/keys.go
This commit is contained in:
@@ -190,7 +190,7 @@ func WalletTransferLimiter(r *ghttp.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
key := fmt.Sprintf(consts.RateLimitKeyTransfer, userId)
|
||||
key := fmt.Sprintf(redis.RateLimitKeyTransfer, userId)
|
||||
|
||||
// 限制: 每个用户每分钟最多转账5次
|
||||
count, err := redis.IncrRateLimit(r.GetCtx(), key, 60) // 60秒窗口
|
||||
@@ -252,7 +252,7 @@ func OSSUploadLimiter(r *ghttp.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
key := fmt.Sprintf(consts.RateLimitKeyUpload, userId)
|
||||
key := fmt.Sprintf(redis.RateLimitKeyUpload, userId)
|
||||
|
||||
// 限制: 每个用户每分钟最多上传10个文件
|
||||
count, err := redis.IncrRateLimit(r.GetCtx(), key, 60) // 60秒窗口
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"gitee.com/red-future---jilin-g/common/log/model/dto"
|
||||
"github.com/gogf/gf/v2/container/gvar"
|
||||
|
||||
"gitee.com/red-future---jilin-g/common/consts"
|
||||
"gitee.com/red-future---jilin-g/common/redis"
|
||||
"gitee.com/red-future---jilin-g/common/utils"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
@@ -280,7 +279,7 @@ func (m *MongoDB) Find(ctx context.Context, filter bson.M, result interface{}, c
|
||||
filter["isDeleted"] = false
|
||||
filterMap := utils.OrderMap(filter)
|
||||
optsMap := listOptionsToMap(ctx, opts...)
|
||||
redisKey := fmt.Sprintf(consts.List, user.TenantId, collection, gconv.String(filterMap), gconv.String(optsMap))
|
||||
redisKey := fmt.Sprintf(redis.List, user.TenantId, collection, gconv.String(filterMap), gconv.String(optsMap))
|
||||
if m.Cache {
|
||||
var resultStr *gvar.Var
|
||||
resultStr, err = redis.RedisClient.Get(ctx, redisKey)
|
||||
@@ -328,7 +327,7 @@ func (m *MongoDB) FindOne(ctx context.Context, filter bson.M, result interface{}
|
||||
}
|
||||
filter["isDeleted"] = false
|
||||
filterMap := utils.OrderMap(filter)
|
||||
redisKey := fmt.Sprintf(consts.One, user.TenantId, collection, gconv.String(filterMap))
|
||||
redisKey := fmt.Sprintf(redis.One, user.TenantId, collection, gconv.String(filterMap))
|
||||
if m.Cache {
|
||||
var resultStr *gvar.Var
|
||||
resultStr, err = redis.RedisClient.Get(ctx, redisKey)
|
||||
@@ -360,7 +359,7 @@ func (m *MongoDB) FindOne(ctx context.Context, filter bson.M, result interface{}
|
||||
return
|
||||
}
|
||||
func (m *MongoDB) CleanRedis(ctx context.Context, filter bson.M, tenantId interface{}, collection string) (err error) {
|
||||
listKeys := fmt.Sprintf(consts.CleanList, tenantId, collection)
|
||||
listKeys := fmt.Sprintf(redis.CleanList, tenantId, collection)
|
||||
keys, err := redis.RedisClient.Keys(ctx, listKeys)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -371,7 +370,7 @@ func (m *MongoDB) CleanRedis(ctx context.Context, filter bson.M, tenantId interf
|
||||
return
|
||||
}
|
||||
}
|
||||
countKeys := fmt.Sprintf(consts.CleanCount, tenantId, collection)
|
||||
countKeys := fmt.Sprintf(redis.CleanCount, tenantId, collection)
|
||||
keys, err = redis.RedisClient.Keys(ctx, countKeys)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -385,7 +384,7 @@ func (m *MongoDB) CleanRedis(ctx context.Context, filter bson.M, tenantId interf
|
||||
filter["isDeleted"] = false
|
||||
delete(filter, "tenantId")
|
||||
filterMap := utils.OrderMap(filter)
|
||||
oneKey := fmt.Sprintf(consts.One, tenantId, collection, gconv.String(filterMap))
|
||||
oneKey := fmt.Sprintf(redis.One, tenantId, collection, gconv.String(filterMap))
|
||||
_, err = redis.RedisClient.Del(ctx, oneKey)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -654,7 +653,7 @@ func (m *MongoDB) Count(ctx context.Context, filter bson.M, collection string) (
|
||||
}
|
||||
filter["isDeleted"] = false
|
||||
filterMap := utils.OrderMap(filter)
|
||||
redisKey := fmt.Sprintf(consts.Count, user.TenantId, collection, gconv.String(filterMap))
|
||||
redisKey := fmt.Sprintf(redis.Count, user.TenantId, collection, gconv.String(filterMap))
|
||||
if m.Cache {
|
||||
var resultStr *gvar.Var
|
||||
resultStr, err = redis.RedisClient.Get(ctx, redisKey)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package consts
|
||||
package redis
|
||||
|
||||
// Redis 数据缓存 Key 常量
|
||||
const (
|
||||
Reference in New Issue
Block a user