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.
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.afterCommit() callbacks, which matters for products that write and invalidate caches within database transactions.Consider adoption when:
RefreshDatabase, DatabaseTransactions) and needs cache flushing to behave correctly inside open transactions.Look elsewhere or defer when:
afterCommit behavior, especially if you rely on custom transaction wrappers.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.
How can I help you explore Laravel packages today?