1. Go to this page and download the library: Download dv0vd/laravel-simple-cache library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dv0vd / laravel-simple-cache example snippets
use Dv0vD\LaravelSimpleCache\CacheTrait;
class ProductRepository
{
use CacheTrait;
public function get(int $id)
{
return $this->rememberCache(
callback: fn () => Product::find($id),
keys: ['id' => $id],
);
}
}
class ProductRepository
{
use CacheTrait;
private const CACHE_MAIN_TAG = 'products';
private const CACHE_TAGS = ['repository', 'models'];
public function get(int $id)
{
return $this->rememberCache(
callback: fn () => Product::find($id),
keys: ['id' => $id],
);
}
}
$this->clearCache();
$this->clearCache(['products']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.