You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With a fresh Laravel 13 installation, the default cache configuration contains:
'serializable_classes' => false,
When caching Eloquent models or Eloquent collections using the Database cache driver, the cached value cannot be restored correctly with the default configuration.
After clearing the cache and configuration, the same code works correctly.
Expected Behavior
I expected one of the following:
Caching Eloquent models to work out of the box with the default configuration, or
The default configuration or documentation to clearly indicate that Eloquent model classes must be explicitly listed in serializable_classes.
Question
Is this the intended behavior?
If so, perhaps the default configuration or documentation could better explain that Eloquent models cannot be cached unless they are explicitly allowed.
Steps To Reproduce
Create a fresh Laravel 13.12.0 application.
Configure the cache driver:
CACHE_STORE=database
Create a basic Product model and migration.
Insert at least one product into the database.
Cache an Eloquent collection:
Cache::remember('products', 3600, function () {
returnProduct::latest()->get();
});
Activity