PHP code example of simplecomplex / cache
1. Go to this page and download the library: Download simplecomplex/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/ */
simplecomplex / cache example snippets
// Bootstrap.
Dependency::genericSet('cache-broker', function () {
return new \SimpleComplex\Cache\CacheBroker();
});
// ...
// Use.
/** @var \Psr\Container\ContainerInterface $container */
$container = Dependency::container();
/** @var \SimpleComplex\Cache\CacheBroker $cache_broker */
$cache_broker = $container->get('cache-broker');
/**
* Create or re-initialize a cache store.
*
* @var \SimpleComplex\Cache\FileCache $cache_store
*/
$cache_store = $cache_broker->getStore(
'some-cache-store',
CacheBroker::CACHE_VARIABLE_TTL
);
unset($cache_broker);
/** @var mixed $whatever */
$whatever = $cache_store->get('some-key', 'the default value');