Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cache Query Laravel Package

laragear/cache-query

Cache your Laravel Eloquent queries and get fast, consistent results without hitting the database on every request. It hooks into the query builder, so you can cache models, counts, and relationships with a simple chainable call.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. laragear/cache-query is a thin, opt-in extension to Laravel's Eloquent query builder: caching is applied per query via a single ->cache() call, and invalidation rides on Eloquent model events. Architecturally this is a good fit for Laravel codebases that already use the framework cache abstraction, because it introduces no new infrastructure, no schema, and no mandatory global behavior. It is best suited to read-heavy, low-write domains (catalogs, CMS content, reference data, dashboards) and is a poor fit for domains requiring strong read-after-write consistency or where writes bypass Eloquent. Note that the package has moved to a new major line: v6.0.0 supersedes v5.0.1. The architecture is unchanged in character (major bumps in this ecosystem typically track Laravel/PHP support windows), but the breaking-change surface is unverified — see below.

Integration feasibility. Low friction: Composer install, package auto-discovery, optional config publish, zero migrations. The practical constraints are (a) supported Laravel/PHP version matrix, (b) cache store capability — tag-based invalidation requires Redis/Memcached/array and will silently degrade on file/database stores, and (c) the requirement that all writes to a cached model flow through Eloquent so that saved/deleted events fire. The last point is an organizational constraint as much as a technical one. For v6.0.0 specifically, (a) is now a blocking gate rather than an informational check: the published release notes contain no summary, deprecation list, or upgrade guide — only a link to the full changelog diff between v5.0.1 and v6.0.0. A major version increment on a package that touches the query builder and cache key derivation must be assumed to carry breaking changes until the diff is read.

Technical risk. Invalidation correctness is the dominant risk. Eloquent events do not fire for DB::table() writes, mass update()/upsert() on the query builder (in some versions), raw SQL, some pivot attach/detach paths, or writes from other services sharing the database. In those cases the package will serve stale results silently — no error, no log. Secondary risks: cache key derivation from SQL plus bindings (collision/ambiguity and unbounded key cardinality), serialized Eloquent models drifting across deploys or schema changes, missing stampede protection on cold keys, and multi-tenant key scoping.

The v6.0.0 release adds a distinct upgrade risk on top of these. Because the changelog summary is empty, the following are unknown and must be diffed before adoption or upgrade: whether key derivation or hashing changed (which invalidates warm caches and can silently change key scope), whether the invalidation event surface changed (new/removed event hooks, pivot handling), whether tag behavior or store fallbacks changed, and which Laravel majors and PHP versions were dropped. A major bump also creates upgrade coupling: if v6 requires a newer Laravel major than the application runs, the package effectively cannot be adopted or upgraded without a framework upgrade. Commercial risk remains real but bounded: modest star count, zero Packagist dependents, low opportunity score, single-maintainer profile, and now a fresh major with no published migration guidance — early 6.x point releases should be treated as potentially containing regressions. MIT licensing permits forking.

Key questions.

  • What exactly changed in v6.0.0, and is there an upgrade guide? Read the full compare diff; the release notes alone are not sufficient.
  • Which Laravel majors and PHP versions does v6.0.0 support, which were dropped relative to v5.0.1, and what is the stated policy for new Laravel majors?
  • Did cache key construction change in v6 — derivation, hashing, tenant/connection/auth scoping? If so, what happens to keys written by v5 during a rolling deploy?
  • Did the invalidation surface change — which write paths trigger invalidation in v6: mass updates, upsert, raw SQL, touch, soft deletes, pivot sync, transactions, queued jobs?
  • Does v6 still support cache tags, and what happens on stores without tag support?
  • Is there stampede/lock protection, and what are the memory characteristics for large result sets?
  • How are serialized models handled across deploys and model refactors?
  • What is the CI/test coverage, security disclosure process, and maintainer bus factor?

Integration Approach

Stack fit. Drop-in for a conventional Laravel monolith or modular monolith on PHP 8.x with Redis or Memcached as the primary cache store. Works with queue workers and Laravel Octane provided the cache store is shared and keys are deterministic; confirm Octane/worker compatibility explicitly against v6.0.0 rather than assuming continuity from v5. It is not a fit for polyglot services writing to the same tables, or for teams that deliberately write through the query builder for performance.

Migration path. Purely additive and reversible, with one caveat introduced by the major bump: because v6 is new, adopt v6 only after the changelog diff is reviewed; if review is not possible in the near term, pinning to the mature v5.0.1 line is the conservative choice, provided it is still supported on your Laravel version. Introduce the package behind an internal repository or query-scope layer rather than sprinkling ->cache() across controllers. Start with one read-heavy endpoint, run cached and uncached paths in parallel in staging, diff results, then expand model-by-model. Rollback is removing the method call or disabling via config — no data migration, no schema rollback. For an existing v5 deployment, treat the v6 upgrade as a separate, isolated change: upgrade in a branch, flush affected cache keys, and watch hit-rate and error logs for a full business cycle before promoting.

Compatibility. Validate against the actual supported matrix before adoption: Laravel version, PHP version, cache driver, and serialization behavior — now explicitly for v6.0.0, and explicitly including any Laravel major that v6 no longer supports. Pay specific attention to tag support by store, key length limits (Redis/Memcached), and whether the package follows Laravel's cache contract changes across majors. Check behavior under Cache::forget vs tag flushing, how it interacts with existing Cache::remember usage and any cache prefixes already configured, and — for v5→v6 — whether previously written keys remain readable or must be flushed.

Sequencing.

  1. Review: read the v5.0.1...v6.0.0 diff, confirm the Laravel/PHP support matrix, and identify any breaking change to keys, events, or config. Do not skip this step on a major bump.
  2. Spike: one endpoint, one model, Redis, measure hit rate, latency, and DB load delta.
  3. Instrument: log hits/misses, add a stale-read canary or short-TTL shadow comparison.
  4. Contract: document that all writes to cached models must go through Eloquent, or add explicit invalidation for exceptions.
  5. Expand: read-mostly models only; exclude high-write and financially sensitive entities.
  6. Codify: lint/review rule or static check that flags query-builder writes to cached tables.
  7. Operate: dashboards, alerting on hit rate and Redis memory, runbook for invalidation incidents.

Operational Impact

Maintenance. Small code surface keeps ongoing cost low, but the project is single-maintainer with a minimal dependent ecosystem, and v6.0.0 is a fresh major with no published migration notes. That resets the "cheap upgrade" assumption: budget an explicit review pass for the v6 upgrade, assume the diff is the only documentation, and assume you own the fork-in-an-emergency scenario. Pin the version explicitly in composer.json (a caret on ^6.0 will pull in early point releases of an unproven major; a tilde or exact pin is defensible for the first few weeks), track Laravel major releases, and budget a recurring compatibility review before each framework upgrade. MIT license makes an internal fork viable but transfers maintenance cost to you.

Support. Community issues only — no vendor SLA. Expect a transient increase in issue volume around a new major as early adopters surface regressions; weight your reading of those issues accordingly rather than treating them as disqualifying. Assign an internal owner (typically the platform or backend lead) and document the supported usage pattern (which models, which stores, which write paths, which package major). Without that ownership, the package becomes tribal knowledge and stale-cache incidents get misdiagnosed as application bugs.

Scaling. The package shifts load from the database to the cache tier. Plan for key cardinality growth (each distinct SQL plus binding combination is a key), Redis memory sizing and eviction policy, and TTL strategy per model. Invalidation is per-key bookkeeping, so bulk writes can create invalidation storms; batch or debounce where possible. Cold-start traffic on expiring keys can produce a thundering herd against the database, so prefer jittered TTLs and, if needed, application-level locking until the package's stampede behavior is confirmed. If a v6 upgrade changes key derivation, treat the cutover as a cold-cache event and pre-warm or throttle accordingly.

Failure modes.

  • Silent stale reads after writes that bypass Eloquent (raw SQL, mass updates, external services).
  • Cache key collision or missing tenant scope, causing cross-tenant data exposure.
  • Tag-based invalidation silently ineffective on stores that lack tag support.
  • Serialization errors after a model or framework upgrade, surfacing as cache misses or exceptions.
  • Undocumented breaking change in v6 key derivation or invalidation surface, producing either permanent misses (harmless but performance-losing) or stale hits (silent correctness failure), and mixed v5/v6 keys during a rolling deploy.
  • Early 6.x regression not caught upstream, given the absence of published release detail and thin dependent ecosystem.
  • Redis eviction or memory pressure causing unpredictable miss rates and DB spikes.
  • Unbounded key growth from ad hoc query parameters (pagination, filters, search terms).
  • Cache poisoning or inconsistent results if keys omit auth or locale scope.

Ramp-up. Low for any Laravel developer — one method call, no new concepts. Realistic onboarding is under a day, but the operational discipline (write-path rules, key-scope review, incident runbook, and for now a major-version upgrade review) is the actual adoption cost. Treat this as a junior-friendly feature with a senior-owned operating model: easy to add, easy to misuse, and quiet when it fails.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle