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 Model Cache Laravel Package

daika7ana/laravel-model-cache

Laravel Model Cache adds transparent query-result caching to Eloquent models, automatically invalidating cached data when models are created, updated, or deleted. Simple trait-based setup with configurable TTLs helps cut database load without changing your existing model code.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Caching strategy and build-vs-buy: Informs whether to adopt a package for model/query cache invalidation versus building custom Cache::forget/observer logic. The package exposes flushModelCache() and flushQueryCache(), suggesting automatic invalidation tied to writes and a lower-maintenance alternative to hand-rolled cache busting.
  • Performance roadmap: Supports decisions to add read-through caching for expensive Eloquent queries and model reads, with invalidation handled at write time.
  • Test-suite reliability and release gating: v1.0.1 fixes a critical failure mode—infinite recursion and unbounded memory use when a cache flush runs inside a transaction, particularly under Laravel’s testing transactions manager. This directly affects confidence in CI and local test runs using transactional test isolation.
  • Transaction correctness: The fix clarifies expected behavior for deferred afterCommit() callbacks, which matters for products that write and invalidate caches within database transactions.
  • Adoption risk assessment: The package is at v1.0.x and recently addressed a severe stability issue. This supports a cautious rollout rather than immediate broad adoption in critical paths.

When to Consider This Package

Consider adoption when:

  • The application is Laravel/PHP and has read-heavy Eloquent access patterns where query/model caching provides measurable latency or cost benefits.
  • You need automatic cache invalidation on writes and want to avoid duplicating observer/event logic across models.
  • Your team uses transactional tests (RefreshDatabase, DatabaseTransactions) and needs cache flushing to behave correctly inside open transactions.
  • You can validate the package against your cache driver, queue configuration, and transaction boundaries before relying on it in production.
  • You are comfortable adopting an early-1.x package with a focused API and reviewing its internals or tests for edge cases.

Look elsewhere or defer when:

  • The application has no meaningful caching layer or the performance gain is not measurable.
  • You require multi-node/distributed cache invalidation guarantees beyond what the package documents; verify compatibility with Redis, database cache, and cache tags where applicable.
  • You need a mature, long-supported dependency with a broad integration surface and strict backward-compatibility commitments.
  • Your architecture already has a centralized cache invalidation service or event-driven cache layer that would conflict with package-managed flushes.
  • You cannot test the package under your exact transaction manager and afterCommit behavior, especially if you rely on custom transaction wrappers.

How to Pitch It (Stakeholders)

Executive summary: This package is a targeted Laravel caching utility for keeping model and query caches consistent when data changes. The v1.0.1 release fixes a serious stability bug: cache flushes triggered inside a database transaction could recursively re-register themselves and exhaust memory, especially in Laravel’s transactional testing environment. That fix reduces CI risk and makes the package safer to evaluate for read-heavy workloads, but the project is still early-stage (v1.0.x) and should be piloted rather than adopted wholesale.

For engineering: The release addresses a real correctness and operability issue in transaction-aware cache invalidation. Validate the fix with your test suite, cache driver, and transaction patterns. The main value proposition is less custom invalidation code and more reliable cache freshness; the main risks are package maturity and distributed-cache edge cases. Recommend a bounded pilot on a read-heavy service with clear rollback criteria.

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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo