Beispiel #1
0
 public static function getCache()
 {
     // return false;
     // clearstatcache();
     $request = new Typecho_Request();
     if ($request->isPost()) {
         // 提交评论时,即有新评论收到时会先清空本文章缓存
         $file_path = str_replace('/comment', '', $request->getPathinfo());
         $file_name = md5($file_path);
         // xcache_set('TEST', $file_path);
         // xcache_set('TEST2', $file_name);
         xcache_unset('Typecho_cache_' . $file_name);
         // 	if (file_exists($file_path)) {
         // 		@chmod($file_path, 0777);
         // 		@unlink($file_path);
         // 	}
         // 	// echo $file_path;
         // echo 1;
     } else {
         // $file_name = md5($request->getPathinfo());
         // var_dump($request);
         // 评论
         $file_name = md5(preg_replace('/(.*)(\\/comment.*)/i', '$1', $request->getPathinfo()));
         if (xcache_isset('Typecho_cache_' . $file_name)) {
             // xcache_set('Typecho_cache_' . $file_name, ob_get_contents(), 600);
             echo xcache_get('Typecho_cache_' . $file_name);
             exit;
         }
         // ob_start();
         // echo '12313';
         // 	$file_path = self::getPath($request->getPathinfo());
         // 	if (file_exists($file_path)) {
         // 		if (self::isValid($file_path)) {
         // 			$handle = @fopen($file_path, 'rb');
         // 			if (@flock($handle, LOCK_SH | LOCK_NB)) {
         // 				fpassthru($handle);
         // 				flock($handle, LOCK_UN);
         // 				fclose($handle);
         // 				exit;
         // 			}
         // 			echo "string2";
         // 			fclose($handle);
         // 		} else {
         // 			@chmod($file_path, 0777);
         // 			@unlink($file_path);
         // 			echo "string3";
         // 		}
         // 	}
     }
 }