perf: heavily optimize jikan cache by pre-warming individual anime objects and using 30-day TTLs for completed shows

This commit is contained in:
2026-04-08 16:31:10 +02:00
parent d70949362e
commit 618b807b3d
4 changed files with 26 additions and 1 deletions

View File

@@ -19,6 +19,11 @@ func (c *Client) GetAnimeByID(id int) (Anime, error) {
return Anime{}, err
}
c.setCache(cacheKey, result.Data, time.Hour*24)
ttl := time.Hour * 24
if result.Data.Status == "Finished Airing" {
ttl = time.Hour * 24 * 30
}
c.setCache(cacheKey, result.Data, ttl)
return result.Data, nil
}