darkghosthunter/rememberable-query
A Laravel package that caches Eloquent query results and remembers them across requests, with automatic invalidation on model changes. Drop-in trait for faster repeated queries.
Architecture fit. This is a micro-package with a single concern: it exposes a remember()-style method (macro and/or trait) on the Eloquent query builder that wraps the terminal get()/first() call in a cache-aside read against the app's configured cache store. That fits Laravel's service-provider-plus-macro idiom cleanly and requires no new infrastructure — it reuses Redis/Memcached/file/database cache already in the stack. The architectural concern is not fit but boundary placement: caching at the query-builder layer is a cross-cutting concern made invisible to downstream call sites, so key correctness and invalidation become system-wide properties that no individual feature team can reason about locally.
Integration feasibility. Technically high: composer require, one provider registration, one line per query. Organizationally low. The repository is archived, the last release was 2022-02-16, there are 0 dependents and 48 stars. That means no upstream triage, no compatibility guarantee against current Laravel/PHP, and no security response path. Treat this as a code snippet dependency, not a maintained library.
Technical risk. Ranked by severity:
Key questions to resolve before any adoption decision:
forget()?Stack fit. Best suited to a Laravel 8–10 monolith or modular monolith with a shared Redis/Memcached cache, and to read-heavy, low-churn queries: lookups, reference/config tables, catalog reads. Poor fit for per-request-unique queries (cache cardinality explodes, hit rate collapses) and write-heavy paths (invalidation burden dominates the win).
Migration path. Do not take this as a live Composer dependency. Two viable paths, both measured in days:
App\Support\RememberableQuery), retaining the MIT license and attribution, and add your own CI matrix.Cache::remember with an explicit, testable key builder. Given the surface area, this is often the cheaper long-term option and gives you first-class control over scope-aware keys.Either path keeps the package's real value — the expressive one-line DX — while removing the abandonment risk.
Compatibility. Pin and test against your target Laravel/PHP matrix explicitly; assume patching is required for Laravel 11+. Even for an internal fork, keep a minimal CI job, because this code sits on a hot read path.
Sequencing.
Verdict: the idea is sound and the opportunity score suggests latent value, but the maintenance and adoption signals (archived, 0 dependents, 2022 release) argue for absorbing the pattern internally rather than depending on the artifact.
Maintenance. You own it. Absolute cost is low given the small surface area, but it is permanent and non-zero. Assign a named owner and hold the fork to the same review, dependency, and security-scanning policy as first-party code — that is the step most likely to be skipped for a "tiny" package.
Support. No upstream support channel, no issue triage, and effectively no community (0 dependents means no peer signal when something breaks). You need an internal ADR documenting the convention: when to use it, when not to, default TTL policy, and the invalidation procedure. Without that, the pattern spreads by imitation and inconsistency compounds.
Scaling. The cache tier becomes a hard dependency of the read path. Watch two metrics specifically: store memory (large result sets) and key cardinality (high-cardinality bindings such as user IDs or timestamps destroy hit rate while inflating memory). Plan for TTL jitter or stale-while-revalidate, since naive expiry produces synchronized recomputation and database spikes.
Failure modes to design for explicitly:
Monitor hit ratio and database QPS as the primary signal; treat a hit-ratio drop or a QPS step-change as the alert.
Ramp-up. Near zero for developers — it is one expressive line over familiar Eloquent, which is precisely the appeal. The real ramp-up cost is cultural: builder-level caching encourages caching before an invalidation plan exists. Pair adoption with a short written guideline and a code-review checklist item ("is the key scoped? what invalidates this?"), and the pattern stays a productivity gain rather than an incident source.
How can I help you explore Laravel packages today?