no racja, czasem faktycznie mózg uśmierca szare komórki skoro nie wpadłem na to wcześnie

Co do bibliotek to raczej staram się z nich nie korzystać jeśli są to duże biblioteki tak jak te Zend Framework. Skoro mogę napisać coś (z wasza pomocą oczywiście) co waży dużo mniej to chyba to lepsze dla serwisu.
Znalazłem dość fajny i kompaktowy skrypt cache.
Czy użylibyście takiego skryptu?
Plik sterownik.php
<?php
define('CACHE_DIR', './sql_cache/');
class sql{
var $connection;
var $result;
var $rows;
var $queries = 0;
var $cache_state =0;
var $cache_file;
var $cache_buffer;
var $cache_ptr;
function sql_connect($host, $user, $pass, $db){
}
function sql_close(){
}
function sql_cache($handle = 0){
$this -> cache_state = 1;
$this -> cache_ptr = 0;
}else{
$this -> cache_state = 2;
$this -> cache_buffer
= array(); $this -> cache_file = CACHE_DIR.'xxx_'.$handle.'.666';
}
}else{
if($this -> cache_state == 2){
file_put_contents
($this -> cache_file
, serialize($this -> cache_buffer
)); }
$this -> cache_state = 0;
}
}
function sql_cache_remove($handle){
unlink(CACHE_DIR
.'xxx_'.$handle.'.666'); }
}
function sql_query($query){
if($this -> cache_state != 1){
$this -> queries++;
}
return 1;
}
}
function sql_fetch_array(){
if($this -> cache_state == 1){
if(!isset($this -> cache_buffer
[$this -> cache_ptr
])){ return 0;
}
$this -> rows = $this -> cache_buffer[$this -> cache_ptr];
$this -> cache_ptr++;
return 1;
}else{
if($this -> cache_state == 2){
// Dodaj do cache
$this -> cache_buffer[] = $this -> rows;
}
return 1;
}
}
return 0;
}
function sql_fetch_row(){
if($this -> cache_state == 1){
// czy koniec bufora?
if(!isset($this -> cache_buffer
[$this -> cache_ptr
])){ return 0;
}
// odczytaj z bufora
$this -> rows = $this -> cache_buffer[$this -> cache_ptr];
$this -> cache_ptr++;
return 1;
}else{
if($this -> cache_state == 2){
// Jeśli tworzymy cache, musimy rekord dodatkowo zapisac w buforze
$this -> cache_buffer[] = $this -> rows;
}
return 1;
}
}
return 0;
}
} // koniec klasy
?>
Plik który używa cache.
<?php
require('./sterownik.php');
$sql = new sql;
$sql -> sql_connect('localhost', 'root', '', 'test');
$sql -> sql_cache('uchwyt');
$sql -> sql_query('SELECT * FROM phpbb_topics');
while($sql -> sql_fetch_row()){
echo $sql -> rows
[0].' - '.$sql -> rows
[1].'<br/>'; }
$sql -> sql_cache();
$sql -> sql_close();
?>
no dobra cache już działa i sprawuje się bardzo dobrze. Mam jednak pytanie czy powyższy kod da się jakoś "dopieścić"
Gdzieś czytałem o jakimś PHP hypercacher czy cóś. Tam podobno wykorzystuje się kompresje i bufory. Czy tutaj da się to zastosować?