mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Function stats, function kill, fcall and fcall_ro (#2486)
This commit is contained in:
48
commands.go
48
commands.go
@ -408,10 +408,14 @@ type Cmdable interface {
|
||||
FunctionLoadReplace(ctx context.Context, code string) *StringCmd
|
||||
FunctionDelete(ctx context.Context, libName string) *StringCmd
|
||||
FunctionFlush(ctx context.Context) *StringCmd
|
||||
FunctionKill(ctx context.Context) *StringCmd
|
||||
FunctionFlushAsync(ctx context.Context) *StringCmd
|
||||
FunctionList(ctx context.Context, q FunctionListQuery) *FunctionListCmd
|
||||
FunctionDump(ctx context.Context) *StringCmd
|
||||
FunctionRestore(ctx context.Context, libDump string) *StringCmd
|
||||
FunctionStats(ctx context.Context) *FunctionStatsCmd
|
||||
FCall(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd
|
||||
FCallRo(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd
|
||||
|
||||
Publish(ctx context.Context, channel string, message interface{}) *IntCmd
|
||||
SPublish(ctx context.Context, channel string, message interface{}) *IntCmd
|
||||
@ -3401,6 +3405,12 @@ func (c cmdable) FunctionFlush(ctx context.Context) *StringCmd {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) FunctionKill(ctx context.Context) *StringCmd {
|
||||
cmd := NewStringCmd(ctx, "function", "kill")
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) FunctionFlushAsync(ctx context.Context) *StringCmd {
|
||||
cmd := NewStringCmd(ctx, "function", "flush", "async")
|
||||
_ = c(ctx, cmd)
|
||||
@ -3434,6 +3444,44 @@ func (c cmdable) FunctionRestore(ctx context.Context, libDump string) *StringCmd
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) FunctionStats(ctx context.Context) *FunctionStatsCmd {
|
||||
cmd := NewFunctionStatsCmd(ctx, "function", "stats")
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (c cmdable) FCall(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd {
|
||||
cmdArgs := fcallArgs("fcall", function, keys, args...)
|
||||
cmd := NewCmd(ctx, cmdArgs...)
|
||||
if len(keys) > 0 {
|
||||
cmd.SetFirstKeyPos(3)
|
||||
}
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
func (c cmdable) FCallRo(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd {
|
||||
cmdArgs := fcallArgs("fcall_ro", function, keys, args...)
|
||||
cmd := NewCmd(ctx, cmdArgs...)
|
||||
if len(keys) > 0 {
|
||||
cmd.SetFirstKeyPos(3)
|
||||
}
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func fcallArgs(command string, function string, keys []string, args ...interface{}) []interface{} {
|
||||
cmdArgs := make([]interface{}, 3+len(keys), 3+len(keys)+len(args))
|
||||
cmdArgs[0] = command
|
||||
cmdArgs[1] = function
|
||||
cmdArgs[2] = len(keys)
|
||||
for i, key := range keys {
|
||||
cmdArgs[3+i] = key
|
||||
}
|
||||
|
||||
cmdArgs = append(cmdArgs, args...)
|
||||
return cmdArgs
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Publish posts the message to the channel.
|
||||
|
Reference in New Issue
Block a user