The safest migration is one painful cache family at a time.
Start with an existing Cache::remember(...) path that already causes inspection or invalidation pain.
- Keep the callback unchanged.
- Move the raw key shape into
Cachelet::for(...). - Put variable inputs in
from(...). - Add
ttl(...). - Add tags,
scope(...), oronStore(...)only when they solve a real operator problem.
Before:
Cache::remember("users.index.page.$page", 600, fn () => $query->paginate());After:
Cachelet::for('users.index')
->from(['page' => $page])
->ttl(600)
->remember(fn () => $query->paginate());If the app already uses a response-cache, query-cache, or model-cache package:
- choose one family
- keep the prefix obvious
- verify the old invalidation behavior
- move the family to Cachelet
- inspect the coordinate output
- replace the old path only after the new invalidation boundary is clear
Do not migrate the whole cache layer just to standardize syntax. Migrate where the operator contract is useful.
Do not add the exporter because the runtime is incomplete.
Add the exporter when the team needs:
- canonical telemetry outside the Laravel process
- shared cache-family evidence in logs or dashboards
- cache behavior data for debugging and audits
- a custom operational surface built from Cachelet records
The runtime contract stays local and useful without the exporter.