Cache DeviantArt API responses #8

closed cmc opened this on 2026-09-11 02:07 UTC

Discussion

cmc 2026-09-11 02:07 UTC

Add an in-memory cache in front of every devianter call: DD, search, deviation, gruser, gallery, favourites, comments. Keyed by endpoint plus arguments. Bounded by entry count or bytes. Singleflight so concurrent requests for one key share a single upstream call. Per-endpoint TTLs, in config with defaults on the order of: DD and search a few minutes, deviations longer, comments shorter.

This is the item the TODO at app/cache.go:3 names. It makes feed polling and /api/random close to free.

Design first: cache interface, key derivation, TTL config keys, eviction, what the hit/miss log looks like. Write the spec to docs/superpowers/specs/ and review before code.

Files: new app/apicache.go, call sites in app/wrapper.go, app/api.go, app/api_json.go, config in app/config.go, docs in SETUP.md.

Verify: unit tests for TTL expiry, singleflight, and bounded size. Two sequential requests for one page make one upstream call.

Roadmap item 1.1, size L. See ROADMAP.md.

closed by commit 90ffcd3e9d by cmc: Serve DeviantArt API responses from the cache

2026-09-11 15:13 UTC

referenced in commit 276d65d64c by cmc: Add an in-memory cache for DeviantArt API responses

2026-09-11 15:13 UTC

referenced in commit bf87ba9fc5 by cmc: Add the api-cache config block and a shared lifetime parser

2026-09-11 15:13 UTC

referenced in commit cf823b1736 by cmc: Add the API response cache implementation plan

2026-09-11 15:13 UTC

referenced in commit 53545b11e2 by cmc: Add the API response cache design

2026-09-11 15:13 UTC