Download the PHP package pulkitjalan/cacheable without Composer
On this page you can find all versions of the php package pulkitjalan/cacheable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pulkitjalan/cacheable
More information about pulkitjalan/cacheable
Files in pulkitjalan/cacheable
Package cacheable
Short Description Automatically cache Eloquent models using the find methods
License MIT
Homepage https://github.com/pulkitjalan/cacheable
Informations about the package cacheable
Cacheable
Automatically cache basic Eloquent models using the
findmethods
Requirements
- PHP >= 5.5.9
- Laravel >= 5.1
Installation
Install via composer - In the terminal
This package makes use of pulkitjalan\multicache which requires a service provider to be registered. So add the following to the providers array in your config/app.php
Usage
Simply use the Cacheable trait in any model you want to be cache automatically.
Caching the model only works with using the find, findMany or findOrFail methods.
If you would like caching behavior like in Laravel 4 then consider using dwightwatson/rememberable which adds the remember function back into eloquent. Both packages can be used together also.
You can optinally set the expiry time in minutes for the model, by default it is set to 1440 minutes (24 hours).
Models are cached using the models table name as the cache tag and the id as the key. There are observers which get registered in the trait to also remove from cache when the saved or deleted.
Caching is only applied to basic models (ones without any conditions added).
The cache can be manually cleared by calling the new refresh method on the cached model which can be found in the Cacheable trait.