예제 #1
0
require_once __DIR__ . '/../vendor/autoload.php';
/**
 * When not specified using a config file or by calling methods, the following parameters are set automatically:
 *
 * cache_expire = 1200 seconds
 * min_cache_file_size = 10
 * file_lock = LOCK_EX | LOCK_NB
 * use_session = false
 *
 */
use PageCache\PageCache;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
//Setup PageCache
$cache = new PageCache();
$cache->setPath(__DIR__ . '/cache/');
//Enable logging
$cache->enableLog();
//Monolog setup. More info on https://github.com/Seldaek/monolog
$logger = new Logger('PageCache');
$logger->pushHandler(new StreamHandler(__DIR__ . '/log/monolog.log', Logger::DEBUG));
//pass Monolog to PageCache
$cache->setLogger($logger);
//Initiate cache engine
$cache->init();
?>
<html>
<body>
<h1>PageCache logging with monolog example</h1>
<h3 style="color: red">This is a demo PageCache page that is going to be cached. Monolog log entries are saved.</h3>
<h3>Check out examples/log/monolog.log file for Monolog entries.</h3>
예제 #2
0
 public function testGetPath()
 {
     $pc = new PageCache();
     $this->assertNull($pc->getPath());
     $pc->setPath(__DIR__ . '/');
     $this->assertNotEmpty($pc->getPath());
 }