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

Laravel Eloquent Query Cache Laravel Package

affordablemobiles/laravel-eloquent-query-cache

Cache your Eloquent query results in Laravel to cut repeated database hits. This package wraps query builder calls with a cache layer, letting you store and invalidate results per model or query for faster responses.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy on the read path. This is the cheapest possible intervention against a read-heavy database: no schema change, no new infrastructure if Redis/Memcached already exists, no rewrite of model code. The decision it informs is sequencing — do we absorb read load with a caching layer, or do we invest in read replicas / denormalized read models / a search service? Start here, measure, escalate only if the numbers demand it.
  • Roadmap triage. A transparent query cache lets you defer infrastructure work and keep shipping features while latency is held roughly flat. Useful when performance complaints exist but don't yet justify a dedicated platform project.
  • Defining a per-surface freshness budget. The real product decision isn't "should we cache" but "how stale may each screen be?" Price and inventory might tolerate 30 seconds; CMS copy an hour; permissions, entitlements and checkout state zero. That budget is a product artifact, and it becomes the TTL configuration. Get it written down before engineering configures anything.
  • Targeting the right surfaces. Good candidates: catalog and listing pages, config/lookup tables, dashboard aggregates that don't need to be live, public API GETs, app bootstrap payloads. Poor candidates: per-user data with high write rates, anything with read-after-write requirements, anything where a stale result is a customer-visible error rather than a mild delay.
  • A measurable success gate. Cache hit ratio and p95 latency on the targeted endpoints become the acceptance criteria. If hit ratio is low because query shapes are too varied, the feature should be killed rather than tuned — that's a decision the PM owns.

When to Consider This Package

Adopt when all of the following hold:

  • Laravel application where Eloquent reads dominate and the same query shapes repeat heavily (high theoretical hit ratio).
  • You already operate a taggable cache store (Redis/Memcached) and have the operational maturity to reason about invalidation and eviction.
  • Writes are concentrated in Eloquent. If writes arrive via raw SQL, bulk imports, queue workers in other codebases, other services, or CDC, the automatic invalidation on save/update/delete will miss them and you will serve stale data.
  • Your queries are predominantly single-model. Joins, aggregates and subqueries are exactly where model-scoped invalidation gets thin — validate each cached query against the invalidation path, not just the happy path.
  • You are willing to own the code rather than depend on a vendor. With 0 stars, 0 dependents, a single maintainer and a 2025 release, treat this as Apache-2.0 source you fork, pin, and test internally. Do not treat it as a supported third-party dependency in a critical path.

Look elsewhere when:

  • Invalidation correctness is business-critical (money, inventory, entitlements). Prefer explicit, hand-written cache keys with deliberate invalidation, or materialized views.
  • You're on a non-taggable driver (file/database) and need bulk or group invalidation.
  • The team won't commit to owning a fork — then use Laravel's native Cache::remember in a repository/read-model layer, or full-response caching, both of which give more control for modest extra code.
  • Query variability is high. Low hit ratio means you pay serialization, memory and invalidation complexity for nothing.

Also sequence honestly: fix N+1s, add missing indexes, and trim over-fetching first. Those are cheaper and usually larger wins than caching the same bad queries.

How to Pitch It (Stakeholders)

To executives: A low-cost, low-risk experiment against read-path latency. No schema migration, no new infrastructure if we already run Redis, and it's reversible in a config change. Frame it as a one-sprint spike with explicit success criteria (hit ratio, p95 on named endpoints, database load) and explicit kill criteria. Its value is that it buys us time on the roadmap — it can defer a read-replica or search-service investment by a quarter or two.

To engineering: Chainable, Eloquent-native API; no model rewrites; keys derived from SQL and bindings; TTL per query or global; invalidation hooked into model writes. Two caveats to state plainly rather than discover later: invalidation is model-scoped, so it needs review for joins, aggregates and out-of-band writers; and tag-based flushing requires a taggable store. Because the package is unproven (no community validation, one maintainer), the recommendation is to vendor or fork it under Apache-2.0, pin the version, and wrap it with integration tests covering our invalidation paths — cheap insurance, and it converts an immature dependency into an internal utility.

Honest risk statement: Expected impact is real but incremental — broad, modest savings rather than a transformation. It is not a substitute for query and index hygiene. If the spike doesn't show a meaningful hit ratio on the targeted endpoints, we drop it and move the effort to the read-replica conversation.

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.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core