feat: warm anime recommendations in background

This commit is contained in:
2026-06-04 11:28:20 +02:00
committed by Milas Holsting
parent 3f482b69be
commit 63802bfc5a

View File

@@ -32,6 +32,16 @@ func (c *Client) GetAnimeRecommendations(ctx context.Context, id int) ([]Recomme
return resp.Data, nil return resp.Data, nil
} }
func (c *Client) WarmAnimeRecommendations(id int) {
url := fmt.Sprintf("%s/anime/%d/recommendations", c.baseURL, id)
cacheKey := fmt.Sprintf("anime:recommendations:%d", id)
c.runAsyncRefresh(func(ctx context.Context) {
var resp RecommendationsResponse
_ = c.getWithCache(ctx, cacheKey, 24*time.Hour, url, &resp)
})
}
// GetAnimeByID returns full anime details; finished series cached 30 days, airing cached 1 day. // GetAnimeByID returns full anime details; finished series cached 30 days, airing cached 1 day.
func (c *Client) GetAnimeByID(ctx context.Context, id int) (Anime, error) { func (c *Client) GetAnimeByID(ctx context.Context, id int) (Anime, error) {
cacheKey := fmt.Sprintf("anime:%d", id) cacheKey := fmt.Sprintf("anime:%d", id)