metaedit

0008. Persist every Last.fm request and response in a permanent archive

Context

The Last.fm API is rate limited (around 5 requests/second per originating IP, with suspension for sustained excess) and its Terms of Service cap stored Last.fm Data at 100 MB. The obvious implementation is a short-TTL cache.

Decision

Keep a persistent, incremental, structured local archive of every response we receive, not a TTL cache. Three layers:

  1. Raw observations — lastfm_request: one append-only row per HTTP attempt, success or failure, with canonicalised params and the Last.fm error code. lastfm_response: the response bodies, content-addressed.
  2. Derived current state — lastfm_artist / lastfm_album / lastfm_track, one row per entity, each carrying the latest_response_id it came from.
  3. Derived graph — lastfm_tag_edge, lastfm_similarity, lastfm_artist_alias, lastfm_entity_tag.

The editor reads through the archive first: a fresh stored response is served without any network call, and the UI shows an “offline” badge when that happens.

Consequences

Alternatives rejected