예제 #1
0
 public function isCached()
 {
     $idenfifier = md5(serialize(func_get_args()));
     if (!$this->_cache[$identifier]) {
         $this->_cache[$identifier] = HCache::create($idenfifier);
     }
     if ($data = $this->_cache[$identifier]->getCache(true)) {
         return $data;
     } else {
         $this->_cache[$identifier]->setStatusSaving();
         return null;
     }
 }
예제 #2
0
<?php

require '../lib/init.php';
define('CACHE_DATA_FOLDER', dirname(__FILE__) . "/cache-folder");
use Hybrid\Cache;
use Hybrid\storages\Disk as DiskStorage;
Cache::addStorageMedia(new DiskStorage());
$cache = Cache::create('key');
if ($data = $cache->getCache(true)) {
    echo "del cache: " . $data;
    echo "\n";
    exit(0);
} else {
    $cache->setStatusSaving();
}
echo "Generando contenido";
sleep(5);
$contenido = md5(rand(1, 99999));
echo $contenido;
echo "\n";
$cache->save($contenido);
예제 #3
0
<?php

require '../lib/init.php';
define('CACHE_DATA_FOLDER', dirname(__FILE__) . "/cache-folder");
use Hybrid\Cache;
use Hybrid\PageCache;
use Hybrid\storages\Redis as RedisStorage;
$storage = new RedisStorage();
$storage->setFormat(RedisStorage::F_CLEAN);
Cache::addStorageMedia($storage);
$page = new PageCache($argv[1]);
$page->setKeyEncodeMethod(Cache::K_UNSERIALIZED_URL);
$page->saveClean(true);
$page->run();
sleep(5);
echo "Example";
?>

No PHP content