Level 7 / Project 14 - Cache Backfill Runner¶
Home: README
Learn Your Way¶
| Read | Build | Watch | Test | Review | Visualize | Try |
|---|---|---|---|---|---|---|
| — | This project | — | — | Flashcards | — | — |
Focus¶
- historical backfill workflow
Why this project exists¶
This project gives you level-appropriate practice in a realistic operations context. Goal: run the baseline, alter behavior, break one assumption, recover safely, and explain the fix.
Run (copy/paste)¶
Use <repo-root> as the folder containing this repository's README.md.
cd <repo-root>/projects/level-7/14-cache-backfill-runner
python project.py --input data/sample_input.txt --output data/output_summary.json
pytest -q
Expected terminal output¶
Expected artifacts¶
data/output_summary.json- Passing tests
- Updated
notes.md
Alter it (required)¶
- Add a
max_backfillslimit so the cache only auto-backfills N times before requiring manual intervention. - Add an
evict_oldest()method that removes the least-recently-added cache entry when at capacity. - Re-run script and tests — verify backfill limiting and eviction work.
Break it (required)¶
- Set
miss_thresholdto 0.0 so every single miss triggers a backfill. - Provide an empty source dict and request keys that do not exist.
- Observe excessive backfills (thrashing) or
Noneresults with misleading stats.
Fix it (required)¶
- Validate that
miss_thresholdis between 0.01 and 1.0 to prevent thrashing. - Skip backfill when the source is empty (nothing to load).
- Add tests for zero threshold, empty source, and backfill count limits.
Explain it (teach-back)¶
- Why does threshold-based backfill prevent unnecessary source reads?
- What happened when miss_threshold was set to zero?
- How did the minimum threshold validation prevent cache thrashing?
- Where would you use cache backfill in a real high-traffic web application?
Mastery check¶
You can move on when you can: - run baseline without docs, - explain one core function line-by-line, - break and recover in one session, - keep tests passing after your change.
Related Concepts¶
- Decorators Explained
- Errors and Debugging
- Files and Paths
- How Imports Work
- Quiz: Decorators Explained
| ← Prev | Home | Next → |
|---|---|---|