提交 867bafca authored 作者: mooncake9527's avatar mooncake9527

rl可直接传入redis conn,省去一个redis conn

上级 0541d00b
...@@ -46,7 +46,7 @@ func NewMemoryCache(keyPrefix string, encode encoding.Encoding, newObject func() ...@@ -46,7 +46,7 @@ func NewMemoryCache(keyPrefix string, encode encoding.Encoding, newObject func()
} }
} }
const logPrefix = "ristretto:" const logPrefix = "[ristretto]"
// Set data // Set data
func (m *memoryCache) Set(ctx context.Context, key string, val interface{}, expiration time.Duration) error { func (m *memoryCache) Set(ctx context.Context, key string, val interface{}, expiration time.Duration) error {
......
...@@ -31,7 +31,7 @@ func (LogHook) DialHook(next redis.DialHook) redis.DialHook { ...@@ -31,7 +31,7 @@ func (LogHook) DialHook(next redis.DialHook) redis.DialHook {
} }
const max = 64 const max = 64
const logPrefix = "redis" const logPrefix = "[redis]"
func (x LogHook) ProcessHook(next redis.ProcessHook) redis.ProcessHook { func (x LogHook) ProcessHook(next redis.ProcessHook) redis.ProcessHook {
return func(ctx context.Context, cmd redis.Cmder) error { return func(ctx context.Context, cmd redis.Cmder) error {
...@@ -41,7 +41,7 @@ func (x LogHook) ProcessHook(next redis.ProcessHook) redis.ProcessHook { ...@@ -41,7 +41,7 @@ func (x LogHook) ProcessHook(next redis.ProcessHook) redis.ProcessHook {
err := next(ctx, cmd) err := next(ctx, cmd)
if err != nil { if err != nil {
if x.logger != nil { if x.logger != nil {
x.logger.Info(Pretty(fmt.Sprintf("%s: %s", logPrefix, cmd.String()), max), x.logger.Info(Pretty(fmt.Sprintf("%s %s", logPrefix, cmd.String()), max),
logger.Any("err", err), logger.Any("err", err),
logger.String("cost", time.Since(st).String()), logger.String("cost", time.Since(st).String()),
logger.String("line", line), logger.String("line", line),
...@@ -50,7 +50,7 @@ func (x LogHook) ProcessHook(next redis.ProcessHook) redis.ProcessHook { ...@@ -50,7 +50,7 @@ func (x LogHook) ProcessHook(next redis.ProcessHook) redis.ProcessHook {
return err return err
} }
if x.logger != nil { if x.logger != nil {
x.logger.Info(Pretty(fmt.Sprintf("%s: %s", logPrefix, cmd.String()), max), x.logger.Info(Pretty(fmt.Sprintf("%s %s", logPrefix, cmd.String()), max),
logger.String("cost", time.Since(st).String()), logger.String("cost", time.Since(st).String()),
logger.String("line", line), logger.String("line", line),
ctxUtil.CtxTraceIDField(ctx)) ctxUtil.CtxTraceIDField(ctx))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论