github.com/shuguocloud/go-zero@v1.3.0/core/stores/redis/process.go (about) 1 package redis 2 3 import ( 4 "strings" 5 6 red "github.com/go-redis/redis" 7 "github.com/shuguocloud/go-zero/core/logx" 8 "github.com/shuguocloud/go-zero/core/mapping" 9 "github.com/shuguocloud/go-zero/core/timex" 10 ) 11 12 func checkDuration(proc func(red.Cmder) error) func(red.Cmder) error { 13 return func(cmd red.Cmder) error { 14 start := timex.Now() 15 16 defer func() { 17 duration := timex.Since(start) 18 if duration > slowThreshold.Load() { 19 var buf strings.Builder 20 for i, arg := range cmd.Args() { 21 if i > 0 { 22 buf.WriteByte(' ') 23 } 24 buf.WriteString(mapping.Repr(arg)) 25 } 26 logx.WithDuration(duration).Slowf("[REDIS] slowcall on executing: %s", buf.String()) 27 } 28 }() 29 30 return proc(cmd) 31 } 32 }