Model caching for Laravel
This package can work independently of the Enso ecosystem.
For live examples and demos, you may visit laravel-enso.com
Comes pre-installed in Enso.
To install outside of Enso:
composer require laravel-enso/rememberable
- comes with a trait that provides helper methods for quick and easy caching usage (setting and retrieving)
- the cache lifetime may be set per-model or per-project
Rememberabletrait in the CachedModel that you want to track
You MUST set the caching duration (in minutes) by either:
- adding a
protected $cacheLifetime = 123;property in your CachedModel
- setting the
enso.config.cacheLifetimeconfiguration value as desired
- adding a
Whenever you need to retrieve a cached model instead of getting it directly from the database:
you should get it from cache:
You may use the global
enso.config.cacheLifetime configuration together with local/per-model
cache lifetime values.
If given, the trait favors the per-model cache lifetime value over the global configuration value, thus you can override the global setting as required.
are welcome. Pull requests are great, but issues are good too.
This package is released under the MIT license.