You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package redis
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
red "github.com/go-redis/redis"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
"github.com/zeromicro/go-zero/core/mapping"
|
|
|
|
"github.com/zeromicro/go-zero/core/timex"
|
|
|
|
)
|
|
|
|
|
|
|
|
func checkDuration(proc func(red.Cmder) error) func(red.Cmder) error {
|
|
|
|
return func(cmd red.Cmder) error {
|
|
|
|
start := timex.Now()
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
duration := timex.Since(start)
|
|
|
|
if duration > slowThreshold.Load() {
|
|
|
|
var buf strings.Builder
|
|
|
|
for i, arg := range cmd.Args() {
|
|
|
|
if i > 0 {
|
|
|
|
buf.WriteByte(' ')
|
|
|
|
}
|
|
|
|
buf.WriteString(mapping.Repr(arg))
|
|
|
|
}
|
|
|
|
logx.WithDuration(duration).Slowf("[REDIS] slowcall on executing: %s", buf.String())
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
return proc(cmd)
|
|
|
|
}
|
|
|
|
}
|