Paths/Backend Engineer/Caching & Performance / Cache Strategies
Choose a Read-Through Policy
A read-through cache keeps the calling code simple - it asks the cache and the cache knows how to load. Write the policy.
Validator
IDLE — checks run live as you type commands; submit when done
01Requirements
live checks- Directory ~/backend/cache exists○
- File ~/backend/cache/policy.yaml exists○
- The config names the strategy and the TTL○
- The config names the key namespace and the serialisation format○
02Walkthrough
3 steps- 01
Write the cache policy
read-through means the cache calls the loader on a miss. The calling code never knows the difference.
echo 'cache:\n strategy: read-through\n namespace: orders:v2\n ttl_seconds: 300\n serialisation: json\n loader: db.orders.fetch' > ~/backend/cache/policy.yaml - 02
Verify the policy
cat prints the policy. Ask what happens when the loader is slow.
cat ~/backend/cache/policy.yaml - 03
Submit for validation
The validator checks the strategy, the TTL and the namespace.
03Stuck?
0 of 3 revealedTake a hint without losing the lab — each one points at the thing to look at, not at the answer.
04AI Tutor
guides, never solvesTell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?
04Notebook
saved locally in this browserlearner@lab — ubuntu:24.04
Session is disposable
↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list