Skip to content

Releases: mikebronner/laravel-model-caching

13.0.2

02 Mar 15:52
228f53c

Choose a tag to compare

Removed

  • 🔥 conflicting composer dev dependencies that prevented installation in Laravel 13.

Full Changelog: 13.0.1...13.0.2

13.0.1

02 Mar 14:40
d308459

Choose a tag to compare

Fixed

  • 🚨 LaraStan warnings related to EloquentBuilder.

Full Changelog: 13.0.0...13.0.1

The Big Catch-Up -- All your issues addressed!

01 Mar 16:49
dfafc62

Choose a tag to compare

✨ Highlights

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.

⬆️ Upgrade Steps

  1. Update your composer.json:
    composer require mikebronner/laravel-model-caching
  2. (Optional) If you want to use the new graceful fallback feature, add to your .env:
    MODEL_CACHE_FALLBACK_TO_DB=true
  3. (Optional) Publish the updated config to get the new fallback-to-database option:
    php artisan modelCache:publish --config

⚠️ Breaking Changes

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.

🚀 New Features

  • Laravel 13 support — Bumped all illuminate/* dependencies to accept ^13.0. (#557)
  • ModelCache Facade — New ModelCache::invalidate() Facade for programmatic cache flushing without Artisan commands. Accepts a single model class or an array. (#571)
  • Graceful fallback to database — When enabled via 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)
  • Cache tags for joined tables — Queries using join(), leftJoin(), etc. now generate cache tags for the joined tables, so writes to joined models correctly invalidate the cache. (#577)
  • Smarter delete/forceDelete invalidation — Cache is now only flushed when delete() or forceDelete() actually removes records (affected rows > 0), avoiding unnecessary invalidation on no-op deletes. (#578)
  • Custom Eloquent builder support — Models that define a custom newEloquentBuilder() method now work correctly with the Cachable trait. (#528)
  • MorphTo and morphedByMany invalidation — Deleting a morphTo-related model or using attach/detach on morphedByMany relationships now correctly flushes the cache. (#575)
  • Bypass cache for pessimistic locking — Queries using lockForUpdate() or sharedLock() now automatically bypass the cache, since locked queries should always hit the database. (#573)

🐛 Bug Fixes

  • belongsToMany()->sync() memory exhaustion — Fixed a memory leak when syncing large pivot datasets. (#569)
  • Cursor pagination crash — Fixed RowValues where type breaking compatibility with Laravel's cursor pagination. (#562)
  • Multi-domain paginator base URL — Paginated results now use the correct base URL per domain in multi-domain applications. (#561)
  • UUID validation crash in cache keys — Fixed a crash when building cache keys containing non-UUID binary strings. (#559)
  • Dynamic $fillable interference — The Cachable trait no longer interferes with models that modify $fillable dynamically (e.g. in __construct()). (#564)
  • Pivot model observer events — Custom pivot model observers now fire correctly on cached models. (#567)
  • Pivot cache invalidation with custom modelsBelongsToMany relationships using custom pivot models (->using()) now correctly invalidate the cache on attach/detach/sync. (#566)
  • MorphTo eager-load cache tag resolution — Fixed cache tag generation for morphTo relationships in eager-load chains. (#579)
  • Model 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)
  • Missing EloquentBuilder import — Added a missing use import in CachedBuilder.php. (#558)

🧹 Housekeeping

  • Removed unnecessary Nova test fixtures and references.
  • Added SECURITY.md with vulnerability reporting instructions.
  • Added Dependabot configuration for automated dependency updates.
  • Comprehensive README overhaul with badges, table of contents, before/after examples, driver comparison table, and real-world usage examples.

🧪 Testing

  • 335+ integration tests across PHP 8.2–8.5 and Laravel 11–13.
  • New test coverage for: 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: 12.0.4...13.0.0

12.1.0-RC3

27 Feb 15:45
181f732

Choose a tag to compare

12.1.0-RC3 Pre-release
Pre-release

Full Changelog: 12.1.0-RC2...12.1.0-RC3

12.1.0-RC2

21 Feb 14:53
20b5737

Choose a tag to compare

12.1.0-RC2 Pre-release
Pre-release

Full Changelog: 12.1.0-RC1...12.1.0-RC2

12.0.4

21 Feb 14:52
0f384b5

Choose a tag to compare

Fixed

Full Changelog: 12.0.3...12.0.4

12.1.0-RC1

17 Feb 23:16
6ca586e

Choose a tag to compare

12.1.0-RC1 Pre-release
Pre-release

Added

Full Changelog: 12.0.3...12.1.0-RC1

12.0.3

17 Feb 23:09
ae605a8

Choose a tag to compare

Fixed

  • 🐛 Escape % in whereIn values before passing to vsprintf (#516) by @mikebronner in #521
  • 🐛 Fixed constrained eager loading producing stale cache results by @mikebronner in #531
  • 🐛 Fixed global macro cache key collisions and proxy in CachedBuilder by @mikebronner in #530

Removed

Full Changelog: 12.0.2...12.0.3

12.0.2

27 Feb 00:35
90901c7

Choose a tag to compare

Fixed

  • Nova tests to pass after upgrading to Nova 5.

12.0.1

26 Feb 23:55
b4fbabd

Choose a tag to compare

Fixed

  • package dependency.