PHP code example of jonathan-neugber / cake-variable-cache
1. Go to this page and download the library: Download jonathan-neugber/cake-variable-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/ */
jonathan-neugber / cake-variable-cache example snippets
use Josegonzalez\CakeQueuesadilla\Queue\Queue;
use VariableCache\Lib\Engine\DatabaseCacheProvider;
use VariableCache\Lib\QueuesadillaCallbacks;
use VariableCache\Model\Entity\CachedVariable;
// Returns an array with name => value
$data = CachedVariableUtility::getAsKeyValue(['foo', 'bar']);
class Statistic
{
use DynamicCalculationTrait;
public static function calculateFoo($amount)
{
return 20000 * $amount;
}
public static function calculateBar($amount)
{
return CachedVariableUtility::get('foo')->content * $amount;
}
}
'foo' => [
'callback' => ['\Statistics', 'calculate'],
'interval' => '5 minutes',
'args' => [
200 // this will be passed as the first argument
],
'variables' => [
'bar' => [
'callback' => ['\Statistics', 'calculate'],
'interval' => '30 seconds',
'args' => [
100
]
]
]
]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.