Laev.Cards (laev v0.1.40)

Copy Markdown View Source

The dozen TMDB fields a list row is made of, kept on disk.

A row needs a title, a year, a poster, an overview, a score, a runtime, and — for a show — how long each season is and whether it has ended. None of that changes hour to hour, and the Watchlist was asking TMDB for all of it every time it opened: seventy-eight requests to draw a page whose answer was the same as last time. Now it asks for what it has never seen and nothing else.

Trimmed on the way in, because the full response is ten times the size and the rest of it is credits, networks and image lists no row has ever read.

Refreshed in the background — a day old for a show, which gains seasons, a week for a film, which doesn't — and never in front of the screen. A card that can't be refreshed stays: a slightly old year is a better row than no row.

Summary

Functions

One card, or nil.

Cards for these {type, id} keys that are already known.

Remember a map of {type, id} => TMDB details, trimmed, in one write.

Which of these keys are old enough to be worth asking about again.

Functions

get(type, id)

One card, or nil.

get_many(keys)

Cards for these {type, id} keys that are already known.

put_many(details)

Remember a map of {type, id} => TMDB details, trimmed, in one write.

stale(keys)

Which of these keys are old enough to be worth asking about again.