fix: address code review findings

This commit is contained in:
2026-08-17 22:14:48 +03:00
parent 777fda95a3
commit 78f662c985
5 changed files with 29 additions and 28 deletions

View File

@@ -270,13 +270,13 @@ func (c *CacheAside) Delete(ctx context.Context, key *CacheKey) error {
// Get retrieves a value from cache by key.
func (c *CacheAside) Get(ctx context.Context, key *CacheKey) ([]byte, error) {
val, err := c.store.Get(ctx, key)
if errors.Is(err, redis.Nil) {
c.metrics.RecordCacheMiss("cache_aside") // record cache aside miss
return nil, nil // cache miss
}
if err != nil {
return nil, fmt.Errorf("cache get: %w", err)
}
if val == nil {
c.metrics.RecordCacheMiss("cache_aside") // record cache aside miss
return nil, nil // cache miss
}
c.metrics.RecordCacheHit("cache_aside") // record cache aside hit
return val, nil
}