Systems on Glass ยท Episode 3 ยท System design

Caching

or: answer the question before anyone asks it

About nine minutes, in two parts: caching for systems, then caching for AI. Generated by Claude as part of my AI-automation side project. The narration is an AI clone of my own voice.

Made with AI, for fun

Systems on Glass is an AI-automation side project of mine. Every episode is generated by Claude (Anthropic's AI, working through Claude Code in my own video studio): the script, the animations and 3D scenes, the edit, and the narration in an AI clone of my voice. I choose the topics, bring the stories from my own work, and review each episode before it goes up. Not affiliated with Anthropic.

Every time an ad loaded, the ad server made seventeen calls to the API I worked on, each due back in about twenty milliseconds. Working the answers out live was far too slow. So we cheated: we answered every question before anyone asked it.

The short version

As in my post about this API, the numbers about that system (seventeen calls, twenty milliseconds, a weekly rebuild) are illustrative: rounded, not the real figures. Prices are Anthropic's published multipliers at the time of writing; check the docs before you budget.

average = hit ร— 0.1 ms + miss ร— 5 ms (illustrative)
90% hits โ†’ 0.1ร—0.9 + 5ร—0.1 โ‰ˆ 0.59 ms ยท 99% hits โ†’ โ‰ˆ 0.15 ms (โ‰ˆ 4ร— faster)
10 prompts, same prefix: no cache = 10 ยท cached = 1.25 + 9 ร— 0.1 โ‰ˆ 2.2 (โ‰ˆ 5ร— cheaper)

The bug I owned up to in the video was real and recent: my video studio cached voice lines by file name, so two different lines with the same name could come back as the same audio. Keying the cache by a hash of the content fixed it, and is the habit I'd suggest for anything you'd pay to make twice.

Further reading

Next episode: Context is RAM, why more context doesn't make your AI agent smarter. Previously: What Is an Agent? All episodes โ†’