⚡Query Caching
Caching options can either be defined at the model level for default values or during the query.
For example, we can set default values for a model called Book
:
Enable/Disable caching on-demand
When opting for default values, keep in mind that setting the $cacheFor
value will cache all queries. To disable caching and instead use a non-caching version, consider dontCache
:
Alternatively, if you want to cache queries by specifying this during the query, consider using cacheFor()
during the query:
Using a DateTime instance like Carbon also works:
Prefixing cache
You may add a default global prefix to the model by specifying $cachePrefix
or do it at the query level:
Last updated