PHP code example of railken / cacheable
1. Go to this page and download the library: Download railken/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/ */
railken / cacheable example snippets
use Railken\Cacheable\CacheableTrait;
use Railken\Cacheable\CacheableContract;
class Foo implements CacheableContract
{
use CacheableTrait;
public function sum(int $x, int $y): int
{
return $x + $y;
}
public function random(): string
{
return str_random(10);
}
}
$foo = new Foo();
$foo->sumCached(2, 8); // 10
$foo->randomCached(); // Return always the same string