Skip to content

Commit f97c2fd

Browse files
committed
add logs for unmarshal errors
1 parent dca9bb0 commit f97c2fd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cache.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ func (c *DCache) GetWithTtl(ctx context.Context, key string, target any, read Re
596596
}
597597
return
598598
} else {
599+
log.Ctx(ctx).Err(err).Msgf("Failed to unmarshal from memory cache for %s", key)
599600
c.recordError(errLabelMemoryUnmarshalFailed)
600601
}
601602
}
@@ -624,6 +625,7 @@ func (c *DCache) GetWithTtl(ctx context.Context, key string, target any, read Re
624625
}
625626
return ve.ValueBytes, nil
626627
} else {
628+
log.Ctx(ctx).Err(err).Msgf("Failed to unmarshal from Redis for %s", key)
627629
c.recordError(errLabelRedisUnmarshalFailed)
628630
}
629631
}
@@ -633,6 +635,7 @@ func (c *DCache) GetWithTtl(ctx context.Context, key string, target any, read Re
633635
// If timeout or not cache-able error, another thread will obtain lock after sleep.
634636
updated, err := c.conn.SetNX(ctx, lockKey(key), "", c.readInterval).Result()
635637
if err != nil {
638+
log.Ctx(ctx).Err(err).Msgf("Failed to get lock by SetNX for %s", key)
636639
c.recordError(errLabelSetRedis)
637640
}
638641
if updated {

0 commit comments

Comments
 (0)