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,467
8년 전 조회 4,457
8년 전 조회 5,492
8년 전 조회 8,478
8년 전 조회 4,016
8년 전 조회 5,203
8년 전 조회 5,006
8년 전 조회 4,704
8년 전 조회 5,937
8년 전 조회 1만
8년 전 조회 6,663
8년 전 조회 7,013
8년 전 조회 6,283
8년 전 조회 1.1만
8년 전 조회 4,088
8년 전 조회 9,655
8년 전 조회 5,658
8년 전 조회 5,153
8년 전 조회 1.1만
8년 전 조회 1.8만
8년 전 조회 5,008
8년 전 조회 6,153
8년 전 조회 4,580
8년 전 조회 5,851
8년 전 조회 6,166
8년 전 조회 3,217
8년 전 조회 7,460
8년 전 조회 6,592
8년 전 조회 4,524
8년 전 조회 1.2만