8115A

파일캐시 부화 줄이기??

[code]

define('cache_time', 1); // 캐싱 5분
define('cache_dir', G5_PATH."/cache/"); // 폴더 경로
define('cache_prefix', "g5_cache_"); // 접두사

function cache_state($cache_name){
    $cache_file = cache_prefix.$cache_name.".php";
    if(is_file(cache_dir.$cache_file) == 1){
        if((time()-filemtime(cache_dir.$cache_file)) >= cache_time*60){
            $cache_state = true;
        }
    }else{
        $cache_state = true;
    }
    return $cache_state;
}
function cache_write($cache_name, $cache_content=""){
    $cache_file = cache_prefix.$cache_name.".php";
    if($cache_content){
  $cache = fopen(cache_dir.$cache_file, "w");
     fwrite($cache, $cache_content);
     fclose($cache);
        $Return = $cache_content;
 }else{
  ob_start();
  include_once(cache_dir.$cache_file);
  $Return = ob_get_contents();
  ob_end_clean();
    }
    return $Return;
}

ob_start();
echo "동해물과 백두산이 마르고 닳도록";
$Content = ob_get_contents();
ob_end_clean();

$cache_name = "main2";
if(cache_state($cache_name)){
 echo cache_write($cache_name, $Content);
}else{
 echo cache_write($cache_name);
}

[/code]

 

 

ob_start();
echo "동해물과 백두산이 마르고 닳도록";
$Content = ob_get_contents();
ob_end_clean();

 

이사이에 mysql 쿼리문이나 그런것들 작동시키면 되겠죠?!

효과가 있을진 모르겠네요..

원랜 db를 이용해서 하긴했는데 파일로 한번 만들어봤어요

 

폴더 생성하고 퍼미션 주셔야 합니다.

|
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
8년 전 조회 5,515
8년 전 조회 4,507
8년 전 조회 5,543
8년 전 조회 8,531
8년 전 조회 4,059
8년 전 조회 5,257
8년 전 조회 5,047
8년 전 조회 4,754
8년 전 조회 5,989
8년 전 조회 1만
8년 전 조회 6,706
8년 전 조회 7,087
8년 전 조회 6,332
8년 전 조회 1.1만
8년 전 조회 4,141
8년 전 조회 9,720
8년 전 조회 5,706
8년 전 조회 5,197
8년 전 조회 1.1만
8년 전 조회 1.8만
8년 전 조회 5,051
8년 전 조회 6,202
8년 전 조회 4,628
8년 전 조회 5,915
8년 전 조회 6,220
8년 전 조회 3,270
8년 전 조회 7,512
8년 전 조회 6,641
8년 전 조회 4,568
8년 전 조회 1.3만