1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00

redis rename key

This commit is contained in:
2023-11-01 16:32:58 +08:00
parent f3918dd02b
commit 5f065de145
3 changed files with 7 additions and 3 deletions

View File

@ -143,6 +143,7 @@ func TestRedisPool(t *testing.T) {
t.Log(client.ConfigGet(context.Background(), "slowlog-log-slower-than").Result())
// client.FunctionLoadReplace(context.Background(), "")
}, redis.RedisOption{
Addr: "192.168.123.100:6379",
PoolSize: 100,

View File

@ -49,7 +49,7 @@ func (r renameKey) renameKey(cmd redis.Cmder) {
}
switch strings.ToUpper(cmd.Name()) {
case "SELECT":
case "SELECT", "FUNCTION":
// 无KEY指令
case
"RENAME", "RENAMENX",
@ -69,8 +69,8 @@ func (r renameKey) renameKey(cmd redis.Cmder) {
case "MSET", "MSETNX":
// 间隔KEYKEY位置规则1,3,5,7
r.rename(args, createSepuence(1, len(args), 2)...)
case "EVAL":
// 命令中包含键数量 EVAL script numkeys [key [key ...]] [arg [arg ...]]
case "EVAL", "EVALSHA", "EVALSHA_RO", "FCALL", "FCALL_RO":
// 命令中包含键数量
if n, ok := args[2].(int); ok && n > 0 {
r.rename(args, createSepuence(3, 3+n, 1)...)
}

View File

@ -21,4 +21,7 @@ func TestEvalName(t *testing.T) {
_, err := rdb.Eval(context.Background(), "return 1", []string{"a1", "a2", "a3"}, "b1", "b2", "b3").Result()
assert.Nil(t, err, err)
v, err := rdb.FunctionLoadReplace(context.Background(), "#!lua name=mylib\nredis.register_function('myfunc1', function() return 'hello world' end)").Result()
t.Log(v, err)
}