AiTeky Original Interactive Learning & Practice Intermediate
PHP and Laravel caching: hit rates, stale prices and the stampede every minute
See how a cache with a time limit cuts database queries, why a price can stay wrong until the entry expires, and fix a popular page whose cache expiry sends a rush of identical queries to the database every minute.
A cache keeps the answer to an expensive question so the next ask is fast. In Laravel, Cache::remember does it in one line. A cache brings two new problems with it: the answer may be stale (out of date) when the data changes, and when a popular entry expires, many requests may all rebuild it at the same moment, a cache stampede.
This course models caching with small Python programs you can run in your browser. Python stands in for PHP: the code is not Laravel, but the time-to-live, the staleness and the stampede it shows are the real behaviour of any cache. Check the Laravel documentation for Cache::remember, atomic locks and cache tags. All numbers are made up.
- Learn lessons explain one idea at a time and let you run it.
- Industry ready lessons decide and justify, and end with interview questions.
No PHP experience is assumed. Basic Python helps.
- ▶ Run code in your browser. Nothing to install
- ✓ Exercises that check themselves
- 📖 Tap a word to see what it means
Locked. Sign up free
Learn
Understand each idea with everyday examples. No coding background needed.
- 01 25 min Free sample 🔒 AiTeky Pass A cache with a time limit Build a small cache with a time-to-live, count how many database queries it saves, and see how the time limit changes the saving.
- 02 25 min 🔒 AiTeky Pass The price that stayed old Change a price while it is cached, count how many requests still see the old one, and see how clearing the cache entry on update removes the stale window.
Industry ready
Real problems from real jobs, and the questions interviewers ask about them.

