Package Data | |
---|---|
Maintainer Username: | valeryq |
Maintainer Contact: | valprogramm@gmail.com (Valery Zakharchenko) |
Package Create Date: | 2015-11-05 |
Package Last Update: | 2016-05-10 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 15:04:09 |
Package Statistics | |
---|---|
Total Downloads: | 100 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 5 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Require this package with composer:
composer require valeryq/cacheable
You must implements the Cacheable contract into your class and you can use the CacheableTrait instead realized methods from contract.
For example (for repositories):
<?php namespace App\Repositories\Cacheable;
use App\Models\Product;
use Valeryq\Cacheable\Contracts\Cacheable;
use Valeryq\Cacheable\Traits\CacheableTrait;
class CacheableProductRepository implements Cacheable
{
use CacheableTrait;
/**
* Find product by id
*
* @param $id
*
* @return Product
* @throws ModelNotFoundException
*/
public function find($id)
{
return $this->cache()->remember('your_key', 60, function() {
return Product::findOrFail($id);
});
}
....
}
The Laravel Cacheable is open-sourced software licensed under the MIT license