Skip to content

perf(availability): keep allowed titles for 10 minutes, denials for seconds - #749

Open
ncbudd wants to merge 1 commit into
snapetech-org:mainfrom
ncbudd:pr/availability-cache
Open

ncbudd wants to merge 1 commit into
snapetech-org:mainfrom
ncbudd:pr/availability-cache

Conversation

@ncbudd

@ncbudd ncbudd commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The problem: viewer-scoped availability answers were cached for only 30 s.
    • Every Requests and Discover answer checks up to 32 titles against the viewer's media server (MAX_MEDIA_AVAILABILITY_CHECKS_PER_RESPONSE).
    • Once the 30 s ran out, the next page asked the media server about the same titles again. From a distant connection that was most of those pages' load time.
  • The change:
    • A title the viewer can open is now kept for 10 minutes (MEDIA_AVAILABILITY_CACHE_TTL_SECONDS). Libraries rarely lose titles that quickly.
    • A denial or a failed check is still kept for only 10 s (MEDIA_AVAILABILITY_ERROR_TTL_SECONDS), so newly shared or recovered access shows within seconds.
    • The mediaavailability cache now holds up to 20,000 answers and 4 MB (was 5,000 and 2 MB), enough for a household's libraries with the longer lifetime.
    • Both TTLs are exported so the test can check them.

Testing

AI assistance

AI tools helped write parts of the code and tests. I reviewed the changes, ran the tests listed above, and checked it on a live install.

…econds

Every Requests and Discover answer checked up to 32 titles against the
viewer's media server again once the 30 s cache ran out, which was most
of those pages' load time from a distant connection. A title the viewer
can open is now kept 10 minutes; a denial or failed check stays 10 s, so
newly shared or recovered access still shows within seconds. The cache
holds up to 20,000 answers (4 MB) for a household's libraries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant