vormkracht10/laravel-permanent-cache
A Laravel package for permanent caching: keep data in the cache indefinitely without expiration. Useful for settings, configuration, and other rarely changing values you want stored persistently. Integrates with Laravel's native cache system through a simple API.
Problem fit. The package addresses a real, quantifiable problem: read-heavy Eloquent models whose data changes rarely but is queried on every request. Cache::rememberForever() plus event-driven invalidation is the canonical pattern for reference data — settings, categories, plans, taxonomies, CMS content, feature flags. The value is DB-load reduction and p95 latency improvement, not architectural change. It is an optimization layer bolted onto the model layer, not a platform.
Surface area. Deliberately small: one trait, model-event listeners, a config file for prefix and key generation, and flush helpers. Small surface means small blast radius and cheap removal. It also means the package does approximately what ~80 lines of Cache::rememberForever plus saved/deleted hooks would do. The TPM implication is that adoption cost and exit cost are both low — the decision should be made on convenience and ongoing maintenance, not strategic lock-in.
Where the value actually lands. Measure before adopting. If a model's read path is a small fraction of request time, or the query is already index-covered and sub-millisecond, permanent caching buys complexity for nothing. Target models with expensive queries (joins, aggregations, JSON columns) or extreme read frequency, and only those.
Technical risk.
Model::query()->update(), raw SQL, seeders, or writes from another service sharing the database. With rememberForever, any such gap produces indefinite staleness — a silent, unbounded failure rather than a TTL-bounded glitch. This is the dominant risk and must be audited per model.^0.3 admits breaking patch releases. With 6 stars and 0 dependents there is effectively no ecosystem validation — we would be among the first production users and would absorb bug discovery.Key questions.
->update() calls, imports, admin SQL, another service?restore covered by the invalidation listeners?illuminate/* constraint?Stack fit. Standard Composer package on Laravel's service-provider and config-publish model; Laravel 12 supported as of v0.3.17. No schema changes, no migrations, no queue requirement. Invalidation is synchronous in the writing process, which keeps the mental model simple but means write latency now includes a cache delete. A shared cache backend (Redis/Memcached) is a hard prerequisite in any multi-node environment.
Compatibility. Pin exactly ("vormkracht10/laravel-permanent-cache": "0.3.17"), not a caret range. Review composer.lock diffs in PRs. Confirm Laravel 12 is a tested target rather than a constraint bump by checking the package's CI matrix or running its suite on our PHP/Laravel combination before committing.
Migration path. There is no incumbent, so this is additive rather than a migration.
Sequencing. Keep this off the critical path of any framework upgrade — framework first, confirm stability, then package. Within the package, sequence models by risk: reference data first, user-visible content second, anything transactional or financial last, if ever. Each model is an independent invalidation contract and deserves its own release.
Alternative to price in. The same behaviour is a trait plus saved/deleted listeners plus rememberForever — roughly one day of in-house work. Compare that against the ongoing cost of reviewing a 0.x dependency every Laravel release. If the package saves a day but adds recurring dependency-review overhead, building in-house can win on total cost of ownership despite losing on initial effort.
Maintenance. Small but non-zero. Review on each Laravel major and each 0.x bump; verify key format and config defaults haven't shifted; re-validate invalidation coverage whenever a new write path touches a cached table. Assign an explicit owner — unowned 0.x dependencies are the ones that break silently. Roughly 2–4 hours per Laravel major plus ad-hoc patch review.
Support. Community-only via GitHub issues. No SLA, single maintainer, minimal adoption. Assume we fix forward ourselves: read the source before adopting, not after, and keep a fork or patch path. The small surface area is what makes this tolerable — the whole package is absorbable in-house if the maintainer goes dark.
Scaling. Reads become single cache round-trips and invalidations are O(1) deletes, so hot-path scaling is generally favourable versus Postgres. Three things to watch: (a) cold-start stampede after a deploy or flush — warm serially or accept one slow window; (b) Redis memory — set per-model key budgets and an eviction policy that cannot take out sessions or queue keys; (c) cache-hit ratio as a first-class per-model metric, alerted on, since a sudden drop usually signals a prefix or connection misconfiguration rather than a code change.
Failure modes.
composer outdated --direct review and an owned dependency-health check.Ramp-up. Low for a mid-level Laravel developer: one trait, one config file, one concept. Budget one to two days end-to-end for the first model including the write-path audit and tests; subsequent models are a few hours each. The real organizational cost is the runbook — flush-on-deploy, cache-health monitoring, and a maintained list of tables with non-Eloquent writers that must call flush explicitly. If that scaffolding isn't funded, the recommendation is not to adopt: permanent caching without invalidation discipline converts a performance win into a data-integrity incident.
How can I help you explore Laravel packages today?