NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #3438 most downloaded on Packagist
Automatic caching for Eloquent models.
Latest stable
13.2.2
Last release 23 days ago
30 Oct 2026
Ships fairly regularly
a new release about every 3 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
9 years old
185 releases · first in 2017
Drag across the ruler to compare, or tap a release to open it.
⚡️ Resolve each eager-loaded relation once per cached read by @mikebronner in https://github.com/mike-bronner/laravel-model-caching/pull/666
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.2.1...13.2.2
🐛 Don't throw a TypeError when a morph type column is cast to backed enum (#657) by @MonikaJov in https://github.com/mike-bronner/laravel-model-cachin
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.2.0...13.2.1
13.2.0 requires PHP 8.3 or later (#645). On PHP 8.2, Composer stays on 13.1.11.
13.2.0 requires PHP 8.3 or later (#645). On PHP 8.2, Composer stays on 13.1.11.
$isCachable is typed boolThe trait now declares protected bool $isCachable (#647). A model or builder that declares $isCachable again without the bool type fails with a fatal error when the class loads.
Fix: declare it as protected bool $isCachable.
newBaseQueryBuilder()13.1.8 added newBaseQueryBuilder() to the Cachable trait. It collided with other traits that define the same method, such as CTE support, so it is gone (#640, #651). A trait rule that names Cachable::newBaseQueryBuilder now fails when the class loads:
Cachable::newBaseQueryBuilder as ...Cachable::newBaseQueryBuilder insteadof ...Fix: delete that rule. Other::newBaseQueryBuilder insteadof Cachable still works.
modelCache:clear no longer empties the whole cache storeOn Redis, the command used to wipe the app's entire cache store, or the whole Redis database when the prefix was empty (#645). It now deletes only the package's own entries.
Fix: if a script relied on it to clear everything, add php artisan cache:clear.
These queries miss the cache once after upgrading, then rebuild:
where(), orWhere() and whereNot() queries on models with global scopes (#647).morphTo eager loads onto models with global scopes (#647).withoutGlobalScopesExcept() calls that keep every scope (#647).where clauses (#647).withPivot(), withTimestamps(), a custom as(), using(), with(), or a related model with $with (#647).fromSub(), union and beforeQuery() bindings that are Stringable objects with non-public state (#647).with('stores') (#641, #653).with() (#647), or that forward a macro or custom builder method (#656).null, false and "" used to share a key, as did 1 and "1".$cachePrefix (#651). A cool-down window that is open at upgrade ends early once.These used to be cached under a key that another query could share, so they could return the wrong rows. They now always read from the database:
where() or having() value that cannot be keyed reliably, such as an object serialize() rejects or a value that holds a resource (#647).afterQuery() callback (#647).Cachable (#647).__toString(), or an array json_encode cannot encode (#656).php artisan modelCache:clear after you deploy. Some changed queries keep their old key text, so until the next write to that table they could read an entry the old version wrote.$isCachable and for trait rules that name newBaseQueryBuilder (items 2 and 3).Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.11...13.2.0
♻️ Replace use of deprecated SplObjectStorage methods by @joshuadwire in https://github.com/mike-bronner/laravel-model-caching/pull/627
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.10...13.2.0
🐛 Tag tables reached via whereHas/whereExists for cache invalidation by @MonikaJov in https://github.com/mike-bronner/laravel-model-caching/pull/623
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.9...13.1.10
🐛 count real bindings, not values entries, in whereIn/whereNotIn cache keys. by @MonikaJov in https://github.com/mike-bronner/laravel-model-caching/pu
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.8...13.1.9
🐛 keep the where-clause boolean in the cache key by @Metilar in https://github.com/mike-bronner/laravel-model-caching/pull/615
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.7...13.1.8
🐛 Cached ofMany eager-loaded relations return null on later paginated pages by @mikebronner in https://github.com/mike-bronner/laravel-model-caching/p
ofMany eager-loaded relations return null on later paginated pages by @mikebronner in https://github.com/mike-bronner/laravel-model-caching/pull/606Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.6...13.1.7
🐛 TypeError in CacheKey::expressionToString() for int-valued Expressions by @mikebronner in https://github.com/mike-bronner/laravel-model-caching/pull
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.5...13.1.6
package requirement in README by @lindiarm in https://github.com/mike-bronner/laravel-model-caching/pull/600
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.4...13.1.5
🐛 Fixed cache clear prefixed redis by @mikebronner in https://github.com/mike-bronner/laravel-model-caching/pull/599
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.3...13.1.4
🐛 Honor enabled flag in flushCache() (#595) + fix order-dependent WhereJsonContains tests by @mikebronner in https://github.com/mike-bronner/laravel-m
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.2...13.1.3
fix: 🐛 Prevent infinite recursion in Cachable trait with inheritance and improve Redis prefix flushing. by @mikebronner in https://github.com/mike-bro
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.1...13.1.2
🐛 serialize cache values to fix Cacheable with serializable_classes (#588) by @mikebronner in https://github.com/mike-bronner/laravel-model-caching/pu
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.0...13.1.1
✨ DynamoDB cache store support by @dgtlss in https://github.com/mike-bronner/laravel-model-caching/pull/586
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.0.6...13.1.0
Fixed composer.json typos.
🐛 cast integer-backed enum values to string in processEnum by @mikebronner in https://github.com/mikebronner/laravel-model-caching/pull/584
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/13.0.3...13.0.4
fix: 🐛 Fixed deep clone of builder state and add integration tests. Thanks @mevisoft!
fix: 🐛 Fixed deep clone of builder state and add integration tests. Thanks @mevisoft!
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/13.0.2...13.0.3
🔥 conflicting composer dev dependencies that prevented installation in Laravel 13.
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/13.0.1...13.0.2
🚨 LaraStan warnings related to EloquentBuilder.
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/13.0.0...13.0.1
Added SECURITY.md with vulnerability reporting instructions.
This release adds Laravel 13 support, introduces several powerful new features — including a ModelCache Facade, graceful fallback when the cache backend is down, and smarter cache invalidation — and fixes a batch of edge-case bugs.
composer.json:composer require mikebronner/laravel-model-caching
.env:MODEL_CACHE_FALLBACK_TO_DB=true
fallback-to-database option:php artisan modelCache:publish --config
Laravel 10 dropped — Minimum Laravel version is now 11. If you are still on Laravel 10, stay on v12.x.
PHP 8.1 dropped — Minimum PHP version is now 8.2. If you are still on PHP 8.1, stay on v12.x.
Existing applications on Laravel 11 or 12 with PHP 8.2+ should be able to upgrade without any code changes.
illuminate/* dependencies to accept ^13.0. (#557)ModelCache::invalidate() Facade for programmatic cache flushing without Artisan commands. Accepts a single model class or an array. (#571)MODEL_CACHE_FALLBACK_TO_DB=true, the package logs a warning and falls back to direct database queries if the cache backend (e.g. Redis) is unavailable, instead of throwing an exception. (#574)join(), leftJoin(), etc. now generate cache tags for the joined tables, so writes to joined models correctly invalidate the cache. (#577)delete() or forceDelete() actually removes records (affected rows > 0), avoiding unnecessary invalidation on no-op deletes. (#578)newEloquentBuilder() method now work correctly with the Cachable trait. (#528)attach/detach on morphedByMany relationships now correctly flushes the cache. (#575)lockForUpdate() or sharedLock() now automatically bypass the cache, since locked queries should always hit the database. (#573)belongsToMany()->sync() memory exhaustion — Fixed a memory leak when syncing large pivot datasets. (#569)RowValues where type breaking compatibility with Laravel's cursor pagination. (#562)$fillable interference — The Cachable trait no longer interferes with models that modify $fillable dynamically (e.g. in __construct()). (#564)BelongsToMany relationships using custom pivot models (->using()) now correctly invalidate the cache on attach/detach/sync. (#566)morphTo relationships in eager-load chains. (#579)retrieved event on cache hit — The Eloquent retrieved event now fires correctly when results are served from cache, matching the behavior of uncached queries. (#563)EloquentBuilder import — Added a missing use import in CachedBuilder.php. (#558)SECURITY.md with vulnerability reporting instructions.reorder() caching, delete/forceDelete flush behavior, custom builders, dynamic fillable, lock queries, cursor pagination, MorphTo eager loads, multi-domain pagination, and pivot model observers.Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.0.4...13.0.0
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.1.0-RC2...12.1.0-RC3
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.1.0-RC2...12.1.0-RC3
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.1.0-RC1...12.1.0-RC2
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.1.0-RC1...12.1.0-RC2
✨ Support custom Eloquent builders on cachable models by @mikebronner #528
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.0.3...12.1.0-RC1
🐛 where clause generation. by @mikebronner in https://github.com/mikebronner/laravel-model-caching/pull/554
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.0.3...12.0.4
🐛 Escape % in whereIn values before passing to vsprintf (#516) by @mikebronner in https://github.com/mikebronner/laravel-model-caching/pull/521
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.0.2...12.0.3
Nova tests to pass after upgrading to Nova 5.
### Fixed - package dependency.
namespace from `genealabs/laravel-model-caching` to `mikebronner/laravel-model-caching`, as this is a good time to make a breaking change, so that it…
genealabs/laravel-model-caching to mikebronner/laravel-model-caching, as this is a good time to make a breaking change, so that it properly reflects its new home.query attribute in strict mode. Thanks @daika7ana!### Fixed - dependency versions.
Laravel 11 compatibility. Thanks @laravel-shift!
cache cooldown checks. Thanks @KieranFYI!
whereHaving clauses not being parsed correctly. Thanks @charlie-waddell!
whereHaving clauses not being parsed correctly. Thanks @charlie-waddell!where clauses that were expressions. Thanks @padre!
missing JsonContainsKey query type. Thanks @jamesRUS52!
JsonContainsKey query type. Thanks @jamesRUS52!processing of enums with null values. Thanks @peter-brennan!
null values. Thanks @peter-brennan!attach() and detach() issues after upgrading to Laravel 10. Thanks @jason-klein
attach() and detach() issues after upgrading to Laravel 10. Thanks @jason-klein'second' in where clause if it is an Expression object.
pagination to be compatible with Laravel 10.3 by adding $total parameter. Thanks @joshuadwire!
$total parameter. Thanks @joshuadwire!parsing of first if it is an Expression object. Thanks @vheins!
first if it is an Expression object. Thanks @vheins!Laravel 10 compatibility. Thanks @faytekin !
pivotSynced event listener to flush cache when performing BelongsToMany::sync. Thanks @d8vjork
enum processing when fetching values from where statements. Thanks @alexhampu !
enum compatibility. Thanks @alexhampu!
support for withoutGlobalScopes(). Thanks @gitwilliam!
withoutGlobalScopes(). Thanks @gitwilliam!functionality for Laravel's full-text search. Thanks @abetwothree!
### Added - Laravel 9 compatibility.
uncatchable relationships being cached. Thanks @joshuadwire!
edge case where binding was not resolved properly. Thanks @dmason30 !
cache functionality for exists(). Thanks @charlie-waddell!
exists(). Thanks @charlie-waddell!caching of paginated queries. Thanks @spencer-leopold!
Slevomat coding standards to be pulled as a dev-dependency only.
the way cache keys were calculated to allow more versatility. Thanks @thyseus
method signature compatibility. Thanks @dmason30 !!
### Updated - to Laravel 8 compatibility.
functionality to inject custom builder class for handling conflicting packages.
### Fixed - typos in test class.
PREDIS dependency. Going forward testing will be done against PHPREDIS, as that is installed by default on Laravel Forge servers and the officially re
support for PHP 7.2 due to incompatibility.
update and insert methods when called on cached relations.
One column per quarter.