调整Key以支持Redis集群版
This commit is contained in:
@@ -50,7 +50,7 @@ func InitPriority(ctx context.Context, re redis.UniversalClient, keyPrefix strin
|
||||
priority: priority,
|
||||
redis: re,
|
||||
logger: conf.logger,
|
||||
redisKey: "timer:priority_" + conf.source + keyPrefix,
|
||||
redisKey: fmt.Sprintf("timer:{%s}:priority_%s", keyPrefix, conf.source),
|
||||
expireTime: conf.expireTime,
|
||||
setInterval: conf.updateInterval,
|
||||
getInterval: conf.getInterval,
|
||||
|
||||
@@ -131,8 +131,8 @@ func TestSetPriorityScenarios(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
redisConn := getRedis()
|
||||
// 删除Key
|
||||
redisConn.Del(ctx, "timer:priority_test22")
|
||||
// 删除Key (new key format with hash tag)
|
||||
redisConn.Del(ctx, "timer:{test22}:priority_")
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
@@ -197,7 +197,7 @@ func TestErrorScenarios(t *testing.T) {
|
||||
|
||||
priority := &Priority{
|
||||
redis: getRedis(),
|
||||
redisKey: "timer:priority_test",
|
||||
redisKey: "timer:{test}:priority_",
|
||||
priority: 100,
|
||||
ctx: ctx,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user