mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Add support for MODULE LOADEX command (#2490)
* Added support for MODULE LOADEX command Co-authored-by: Anurag Bandyopadhyay <angbpy@gmail.com>
This commit is contained in:
31
commands.go
31
commands.go
@ -497,6 +497,8 @@ type Cmdable interface {
|
||||
GeoHash(ctx context.Context, key string, members ...string) *StringSliceCmd
|
||||
|
||||
ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd
|
||||
|
||||
ModuleLoadex(ctx context.Context, conf *ModuleLoadexConfig) *StringCmd
|
||||
}
|
||||
|
||||
type StatefulCmdable interface {
|
||||
@ -3888,3 +3890,32 @@ func (c cmdable) ACLDryRun(ctx context.Context, username string, command ...inte
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// ModuleLoadexConfig struct is used to specify the arguments for the MODULE LOADEX command of redis.
|
||||
// `MODULE LOADEX path [CONFIG name value [CONFIG name value ...]] [ARGS args [args ...]]`
|
||||
type ModuleLoadexConfig struct {
|
||||
Path string
|
||||
Conf map[string]interface{}
|
||||
Args []interface{}
|
||||
}
|
||||
|
||||
func (c *ModuleLoadexConfig) toArgs() []interface{} {
|
||||
args := make([]interface{}, 3, 3+len(c.Conf)*3+len(c.Args)*2)
|
||||
args[0] = "MODULE"
|
||||
args[1] = "LOADEX"
|
||||
args[2] = c.Path
|
||||
for k, v := range c.Conf {
|
||||
args = append(args, "CONFIG", k, v)
|
||||
}
|
||||
for _, arg := range c.Args {
|
||||
args = append(args, "ARGS", arg)
|
||||
}
|
||||
return args
|
||||
}
|
||||
|
||||
// ModuleLoadex Redis `MODULE LOADEX path [CONFIG name value [CONFIG name value ...]] [ARGS args [args ...]]` command.
|
||||
func (c cmdable) ModuleLoadex(ctx context.Context, conf *ModuleLoadexConfig) *StringCmd {
|
||||
cmd := NewStringCmd(ctx, conf.toArgs()...)
|
||||
_ = c(ctx, cmd)
|
||||
return cmd
|
||||
}
|
||||
|
Reference in New Issue
Block a user