mikebronner/laravel-model-caching
Speeds up Eloquent by automatically caching model queries and relationships, cutting repetitive database hits. Drop-in package with cache tagging support, configurable cache stores and TTLs, and easy invalidation on model updates—ideal for high-traffic Laravel apps.
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
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.5...13.1.6
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.4...13.1.5
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.3...13.1.4
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.2...13.1.3
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.1...13.1.2
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.0...13.1.1
Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.0.6...13.1.0
mikebronner private account to mike-bronner org account.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!
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/13.0.2...13.0.3
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/13.0.1...13.0.2
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/13.0.0...13.0.1
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.0.3...12.0.4
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.0.3...12.1.0-RC1
Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.0.2...12.0.3
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!whereHaving clauses not being parsed correctly. Thanks @charlie-waddell!JsonContainsKey query type. Thanks @jamesRUS52!null values. Thanks @peter-brennan!attach() and detach() issues after upgrading to Laravel 10. Thanks @jason-klein$total parameter. Thanks @joshuadwire!first if it is an Expression object. Thanks @vheins!How can I help you explore Laravel packages today?