1. Go to this page and download the library: Download vagento/cacheable 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/ */
vagento / cacheable example snippets
use Vagento\Cacheable\Traits\Cacheable;
class MyClass
{
use Cacheable; // Add this trait
public function myMethod()
{
// Big computational task
return $bigData;
}
}
$myClass = new MyClass();
$result = $myClass->myMethodCached();
$myClass = new MyClass();
// Optional: Cache usage, will toggle caching on or off
// Default: true
$myClass->setCacheUsage(false);
// Optional: Laravel cache tags @see https://laravel.com/docs/8.x/cache#cache-tags
// Default: null
$myClass->setCacheTags('my-method-tag');
// Optional: Time to live
// Default: null
$myClass->setTtl(60);
$myClass->setTtl(Carbon::now()->addMinutes(30)->toDateTime());
// Chaining
$result = $myClass->setCacheUsage(true)->setCacheTags(['method', 'something-else'])->setTtl(60)->myMethodCached();
/**
* @method array myMethodCached()
*/
class MyClass
{
use Cacheable;
public function myMethod(): array
{
// Big computational task
return $bigData;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.