1. Go to this page and download the library: Download mmamedov/page-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/ */
mmamedov / page-cache example snippets
{
$cache = new PageCache\PageCache();
$cache->config()
->setCachePath('/your/path/')
->setEnableLog(true);
$cache->init();
} catch (\Exception $e) {
// Log PageCache error or simply do nothing.
// In case of PageCache error, page will load normally, without cache.
}
//rest of your PHP page code, everything below will be cached
Naroga\RedisCache\Redis;
use Predis\Client;
$config = array(
'scheme' => 'tcp',
'host' => 'localhost',
'port' => 6379
);
$redis = new Redis(new Client($config));
$cache = new PageCache\PageCache();
$cache->setCacheAdapter($redis);
$cache->init();
//rest of your PHP page code, everything below will be cached
$cache = new PageCache\PageCache();
$cache->setStrategy(new MyOwnStrategy());
// Optional system-wide cache config
use PageCache\PageCache;
$config_file_ = __DIR__.'/config.php';
$cache = new PageCache($config_file_);
// You can overwrite or get configuration parameters like this:
$cache->config()->getFileLock();
$cache->config()->setUseSession(true);