1. Go to this page and download the library: Download roolith/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/ */
roolith / cache example snippets
define('ROOLITH_CACHE_DIR', __DIR__. '/cache');
use Roolith\Caching\Cache\CacheFactory;
// will save cache
CacheFactory::put('a', 'b', 3600);
// will retrive cache
CacheFactory::get('a');
// you can select driver and store
CacheFactory::driver('file')->put('a', 'b', 3600);
// will return boolean
CacheFactory::has('foo');
// will delete cache item
CacheFactory::remove('foo');
// will delete all cache item
CacheFactory::flush();
use Roolith\Caching\Cache\Cache;
$cache = new Cache();
$cache->driver('file', ['dir' => __DIR__. '/cache']);
print_r($cache->get('foo'));
use Roolith\Caching\Driver\FileDriver;
use Roolith\Caching\Cache\Pool;
$fileDriver = new FileDriver(['dir' => __DIR__. '/cache']);
$pool = new Pool($fileDriver);
$item = $pool->getItem('foo');
if (!$item->isHit()) {
$item->set([1, 2, 3])->expiresAfter(3600);
$pool->save($item);
}
print_r($item->get());
use Roolith\Caching\Cache\SimpleCache;
use Roolith\Caching\Driver\FileDriver;
$fileDriver = new FileDriver(['dir' => __DIR__. '/cache']);
$simpleCache = new SimpleCache($fileDriver);
print_r($simpleCache->get('foo'));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.