Carga con alta reutilización
Temporal locality improves the hit rate.
Cálculo / simulación localExperimento educativo local, sin API externa. Los datos sintéticos no son mediciones de producción.
Study guide & lesson outline
LEARNING CONTRACTUnderstand → implement → investigate
Goal: explain the mechanism in this lesson, reproduce one example and test a failure case. Reading alone does not mark mastery.
- Understand: state assumptions, shapes/units and a counterexample.
- Implement: reproduce a numerical example and inspect boundaries.
- Investigate: compare one alternative under a matched budget.
02 · Predice y configura
Las notas técnicas, los parámetros y las respuestas están actualmente en inglés.
03 · Analiza la evidencia
Métodos y referencias
Exact-key LRU simulation. TTL starts on insertion and does not refresh on hits. Expired entries are removed before each request. Assumes stable outputs within TTL. A real cache key should include tenant, model/version, prompt and generation settings; this lab uses letters.
Text / 原始公式
hit rate=hits/requests; cost=misses×costPerMiss; mean latency=(hits×hitMs+misses×missMs)/requests
Cross-tenant key reuse can expose private data; stale cached answers may be incorrect.
Redis · eviction and TTL policies ↗Preguntas de práctica
cache-4 / 01What does “High reuse workload” test?
Temporal locality improves the hit rate.
Original teaching answer / local derivation. Method reference: Redis · eviction and TTL policies ↗
Abrir laboratorio →cache-4 / 02Which computation produces the result in “High reuse workload”?
hit
Original teaching answer / local derivation. Method reference: Redis · eviction and TTL policies ↗
Abrir laboratorio →cache-4 / 03What is the baseline configuration for “High reuse workload”?
{"keys":"A,A,A,A,B,B,A,A","capacity":3,"ttl":60,"interval":1,"cost":0.01,"missMs":1000,"hitMs":10}
Original teaching answer / local derivation. Method reference: Redis · eviction and TTL policies ↗
Abrir laboratorio →cache-4 / 04What numerical result should you check for “High reuse workload”?
{"Hit rate":0.75,"Misses":2,"Cost USD":0.02,"Mean latency (ms)":257.5}
Original teaching answer / local derivation. Method reference: Redis · eviction and TTL policies ↗
Abrir laboratorio →cache-4 / 05How would you run a controlled comparison for “High reuse workload”?
Keep the supplied fixture and other settings fixed; change capacity. Inspect hit/miss trace, eviction order, cost and mean latency.
Original teaching answer / local derivation. Method reference: Redis · eviction and TTL policies ↗
Abrir laboratorio →cache-4 / 06What failure could invalidate a conclusion from “High reuse workload”?
Cross-tenant key reuse can expose private data; stale cached answers may be incorrect.
Original teaching answer / local derivation. Method reference: Redis · eviction and TTL policies ↗
Abrir laboratorio →cache-4 / 07Is “High reuse workload” a benchmark of a deployed language model?
No. Exact-key LRU simulation. TTL starts on insertion and does not refresh on hits. Expired entries are removed before each request. Assumes stable outputs within TTL. A real cache key should include tenant, model/version, prompt and generation settings; this lab uses letters.
Original teaching answer / local derivation. Method reference: Redis · eviction and TTL policies ↗
Abrir laboratorio →cache-4 / 08Which evidence should you report for “High reuse workload”?
Inspect hit/miss trace, eviction order, cost and mean latency. Export inputs, engine, result and method; distinguish synthetic fixtures from observed production data.
Original teaching answer / local derivation. Method reference: Redis · eviction and TTL policies ↗
Abrir laboratorio →cache-4 / 09How can another researcher reproduce “High reuse workload”?
Open cache-4, reset the preset, retain the exact inputs and run. The calculation is deterministic for identical inputs.
Original teaching answer / local derivation. Method reference: Redis · eviction and TTL policies ↗
Abrir laboratorio →cache-4 / 10What is the next validation step after “High reuse workload”?
Cross-tenant key reuse can expose private data; stale cached answers may be incorrect. Test the hypothesis on a representative held-out workload and document a baseline, success metric and stopping rule before claiming deployment readiness.
Original teaching answer / local derivation. Method reference: Redis · eviction and TTL policies ↗
Abrir laboratorio →Assumptions, implementation & acceptance
TTL starts at insertion and is not refreshed on a hit. LRU order does refresh. Request keys share one synthetic namespace; production keys must include model, parameters and authorization scope.
Engine formulas, scenario presets and numerical safeguards reviewed. Seeded synthetic inputs are not a production benchmark.
Before running: predict a boundary case
Temporal locality improves the hit rate.
Hint: isolate the assumption
Keep the baseline input fixed, change one parameter or boundary, and compare both the numerical result and the claimed units. A passing example verifies this fixture only.
Minimal executable example
Save the example and linked modules in one folder. Use Node.js 22 or newer, then run node cache-4.mjs. No third-party runtime dependencies.
import {calculate,network} from './academy-core.mjs';
const params={
"keys": "A,A,A,A,B,B,A,A",
"capacity": 3,
"ttl": 60,
"interval": 1,
"cost": 0.01,
"missMs": 1000,
"hitMs": 10
};
const result=calculate('cache',params);
console.log(result.metrics);Test and transfer
Temporal locality improves the hit rate.
Record input, code version, expected result and observed result in the notebook below. Then construct a counterexample that violates the assumption above and explain why the original conclusion no longer follows.
Download complete kit (.tar.gz) · Complete reference kit and regression checksPredict, test and keep evidence
Before revealing an answer, predict one result. After the exercise, record the discrepancy and a transfer test. Saved locally across language editions.
Open notebook / export / clear →The mathematical review scope is recorded per lesson. It does not establish empirical paper reproduction; report suspected errors in your notes. Review scope