fix: don't cache empty jikan responses

This commit is contained in:
2026-04-30 08:14:48 +02:00
parent 64c1295a8b
commit 2f96e0a000

View File

@@ -271,6 +271,12 @@ func (c *Client) getWithCache(ctx context.Context, cacheKey string, ttl time.Dur
return err
}
// Don't cache empty results to avoid caching failures
if isEmptyResult(out) {
log.Printf("jikan: fetched data for %s is empty, not caching", cacheKey)
return fmt.Errorf("jikan: empty response for %s", cacheKey)
}
c.setCache(ctx, cacheKey, out, ttl)
return nil
}