사이트 내 전체검색
그누보드
검색목록
[튜닝] common.php 에서 config 테이블 자주 읽지 않게 하기
최고관리자
https://cmd.kr/gnu/1 URL이 복사되었습니다.

본문

작성: freeimage.kr 김성대 08.12.26
제목: [튜닝] common.php 에서 config 테이블 자주 읽지 않게 하기

원본: config.php 
 $config = sql_fetch(" select * from $g4[config_table] ");

개선:
$filename=$g4['path']."/../tmp/config.save";
if (time()-@filemtime($filename)>600) {
 $config = sql_fetch(" select * from $g4[config_table] ");
 file_put_contents($filename,serialize($config));
}
else {
 $config=unserialize(file_get_contents($filename));
}

원본: adm/config_form_update.php
goto_url("./config_form.php");

개선:
$filename=$g4['path']."/../tmp/config.save";
$config = sql_fetch(" select * from $g4[config_table] ");
file_put_contents($filename,serialize($config));
goto_url("./config_form.php");


설명: 임시파일에 config 내용을 저장한뒤 600초 미만이면 파일에서 읽고,
그 이상이면 테이블에서 읽어서 다시 저장한다.

보안:
  1.config.save를 웹에서 접속가능한 위치에 저장하며 안된다. (웹에서 다운가능)
  2. web 에서 쓰기가 가능해야 하므로 파일권한을  nobody 가 쓰기 가능하도록 해야한다.
  3. 파일명,위치는 공개하지 말라.

참고:
효과에 대해서는 아직 미확인임.. 트래픽을 유발시킨뒤 DB에서 읽는것이 빠른지 파일처리가 빠른지
비교해봐야 할것같음..

댓글목록

등록된 댓글이 없습니다.

그누보드
24 (1/1P)

Search

Copyright © Cmd 명령어 18.218.145.131