go-redis/redis · error
MemoryUsage expects single sample count
Error message
MemoryUsage expects single sample count
What it means
Error "MemoryUsage expects single sample count" thrown in go-redis/redis.
Source
Thrown at commands.go:856
func (c cmdable) Time(ctx context.Context) *TimeCmd {
cmd := NewTimeCmd(ctx, "time")
_ = c(ctx, cmd)
return cmd
}
func (c cmdable) DebugObject(ctx context.Context, key string) *StringCmd {
cmd := NewStringCmd(ctx, "debug", "object", key)
_ = c(ctx, cmd)
return cmd
}
func (c cmdable) MemoryUsage(ctx context.Context, key string, samples ...int) *IntCmd {
args := []interface{}{"memory", "usage", key}
if len(samples) > 0 {
if len(samples) != 1 {
cmd := NewIntCmd(ctx)
cmd.SetErr(errors.New("MemoryUsage expects single sample count"))
return cmd
}
args = append(args, "SAMPLES", samples[0])
}
cmd := NewIntCmd(ctx, args...)
cmd.SetFirstKeyPos(2)
_ = 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{}View on GitHub (pinned to 36d97525cd)
Solutions
- Pass a single sample count value to MemoryUsage (or none), not several
- Use the typed MemoryUsage signature instead of spreading a slice
When it happens
Trigger: Thrown at commands.go:856 when the library encounters an invalid state.
Common situations: Guard variadic count arguments with a length check before the call.
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/1ed528312683c898.json.
Report an issue: GitHub.