Weave Code
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 Caching Laravel Package

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.

View on GitHub
Deep Wiki
Context7
13.1.7

Fixed

Changed

New Contributors

Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.6...13.1.7

13.1.6

Fixed

Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.5...13.1.6

13.1.3

Fixed

Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.2...13.1.3

13.1.2

Fixed

New Contributors

Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.1...13.1.2

13.1.1

Fixed

Full Changelog: https://github.com/mike-bronner/laravel-model-caching/compare/13.1.0...13.1.1

13.0.6

Fixed

  • composer.json typos.
13.0.5

Changed

  • repo owner from mikebronner private account to mike-bronner org account.
13.0.4

Fixed

Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/13.0.3...13.0.4

13.0.2

Removed

  • 🔥 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

13.0.1

Fixed

  • 🚨 LaraStan warnings related to EloquentBuilder.

Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/13.0.0...13.0.1

13.0.0

✨ 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: https://github.com/mikebronner/laravel-model-caching/compare/12.0.4...13.0.0

12.1.0-RC1

Added

  • ✨ 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

12.0.3

Fixed

Removed

Full Changelog: https://github.com/mikebronner/laravel-model-caching/compare/12.0.2...12.0.3

12.0.2

Fixed

  • Nova tests to pass after upgrading to Nova 5.
12.0.1

Fixed

  • package dependency.
12.0.0

Added

Changed

  • 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 properly reflects its new home.

Fixed

  • nullable method parameters. Thanks @d8vjork!
  • cache key issue. Thanks @JC5!
  • query attribute in strict mode. Thanks @daika7ana!
11.0.1

Fixed

  • dependency versions.
11.0.0

Added

0.13.9

Fixed

0.13.8

Fixed

0.13.7

Fixed

  • where clauses that were expressions. Thanks @padre!
0.13.6

Fixed

  • missing JsonContainsKey query type. Thanks @jamesRUS52!
0.13.5

Fixed

0.13.4

Fixed

  • attach() and detach() issues after upgrading to Laravel 10. Thanks @jason-klein
0.13.3

Fixed

  • 'second' in where clause if it is an Expression object.
0.13.2

Changed

  • pagination to be compatible with Laravel 10.3 by adding $total parameter. Thanks @joshuadwire!
0.13.1

Fixed

  • parsing of first if it is an Expression object. Thanks @vheins!
0.13.0

Added

  • Laravel 10 compatibility. Thanks @faytekin !
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky