Model cache timeout option
magnetic5355 opened this issue · 1 comments
Is your feature request related to a problem? Please describe.
When utilizing applications that can make changes directly in the db or an outside process but you can still return stale data for a period of time, a configuration option is needed to specify cache time on the command and model.
For instance if you have 1000's of hits a minute and you can return stale data that was changed by an outside process for a minute; you can save 1000's of db queries.
Describe the solution you'd like
Add option to set cacheTimeout on the model and on the query builder
Describe alternatives you've considered
Jobs that clear model cache by model name
Hi @caesarcxiv, Thanks for writing in.
The solution for your use-case is to manually flush the cache of the affected model(s) directly after the database updates have completed using the [model name]::flushCache()
or $model->flushCache()
method, or alternatively using the artisan command
php artisan modelCache:clear --model=App\Model