Beispiel #1
0
 public static function setCache()
 {
     $request = new Typecho_Request();
     $file_name = md5($request->getPathinfo());
     // $file_path = self::getPath($request->getPathinfo());
     // 写入xcache 默认10分钟
     if (!xcache_isset($file_name)) {
         xcache_set('Typecho_cache_' . $file_name, ob_get_contents(), 600);
     }
     // var_dump($request->getPathinfo());
     // if (!file_exists($file_path)) {
     // 	$handle = @fopen($file_path, 'wb');
     // 	if (@flock($handle, LOCK_EX | LOCK_NB)) {
     // 		// xcache_set('tmp', ob_get_contents());
     // 		fwrite($handle, ob_get_contents() . "<!-- This Is A Cache File Created At " . date("Y-m-d H:i:s", time() + 28800) . " Power By http://www.shionco.com -->");
     // 		flock($handle, LOCK_UN);
     // 	}
     // 	fclose($handle);
     // }
 }
Beispiel #2
0
 public static function setCache()
 {
     global $noCache;
     if (!$noCache) {
         return;
     }
     $request = new Typecho_Request();
     $requestHash = $request->getPathinfo();
     #尝试存入缓存
     $cache = ob_get_contents();
     self::set($requestHash, $cache);
     $config = Helper::options()->plugin(self::$pluginName);
     if ($config->cacheTester) {
         echo '<small style="font-size:10px;color:#bbb;">生成缓存内容:' . round(strlen($cache) / 1024, 2) . 'K 将会缓存:' . $config->cacheTime . '天 期间如有新文章发布、新评论产生将自动刷新缓存</small>';
     }
     return;
 }