1. Go to this page and download the library: Download christianklisch/phpcache 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/ */
$myString = $cache->cacheVal('String to cache','cachingID');
$myObj = new FooBar();
$obj = $cache->cacheVal($myObj, $myObj->getId());
$myObj = new FooBar();
/**
* Setting get-functions for primary keys of classes
* @param array $primkeys Associative array of class primary-key-function
*/
$cache->setPrimaryKeys(array(
'FooBar' => 'getId'
));
$obj = $cache->cacheVal($myObj);
/**
* check, if key or object in first parameter is cached. Returns true, if cached
* @return bool
*/
if($cache->isCached($key))
$obj = $cache->cacheVal($myObj, $key);
else
$obj = $logic->calcVal($key);
/**
* cache function result and return it
* @return object
*/
$key = 1110;
$result = $cache->cacheFun(
function () use ($key, $logic) {
return $logic->getComplexResult();
}
);
echo "result: ".$result;
/**
* delete old cached files
*/
$cache->gc();
/**
* delete all cached files
*/
$cache->clearCache();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.