insomnicles / laracache
A trait for caching Laravel models
v0.0.9
2022-04-27 18:03 UTC
Requires
- illuminate/support: >=9.0
Requires (Dev)
- orchestra/testbench: 8
- phpunit/phpunit: ~9.0
README
A trait for accessing Laravel Eloquent models directly from Cache
Source code packagist.
Installation
Via Composer
$ composer require insomnicles/laracache
Usage
Make sure your app is connected to a Cache: memcache, redis, etc.
- If you're using Sail in Laravel 8+, this is setup out of the box
Add the Cachable Trait to your Model; for example, for the User Model
use Insomnicles\Laracache\Cachable.php
class User {
use Cachable;
}
Use the Cached Model via Eloquent-like methods
User::refreshCache();
User::allInCache();
Change log
Please see the changelog for more information on what has changed recently.
License
MIT. Please see the license file for more information.