I know there were some issues on storing files of cache to retrieve them fast.
My solution was - creat subdirectiry structure like squid-cache uses.
But there was a problem - we do not know when cache old or not.
My solution was - checkpoint variable to differ old cache content from new content to know when just recache it.
Of course this structure can grow without limitations -but it's not a problem make cron script to just remove files from cache
cache need files/cache directory
Here my custom cache.inc is:
<?php
/*
*
* Filecache by Ilya V. "brainstorm" Azarov, brainstorm.name
*
*
*/
class cache_cc{
var $data, $created, $expire, $headers, $checkpoint;
function cache_cc($c){
$this->data = $c['data'];
$this->created = $c['created'];
$this->expire = $c['expire'];
$this->headers = $c['headers'];
$this->checkpoint = $c['checkpoint'];
}
}
function filecache_get_checkpoint($table){
if($table == 'filecache_checkpoint') return 0;
$key = $table;
$lock = filecache_lockpath('filecache_checkpoint', $key);
$dir = filecache_md5path('filecache_checkpoint', $key);
$src = filecache_name('filecache_checkpoint', $key);
$f = fopen($lock, 'w+');
if(flock($f, LOCK_SH) && file_exists($src) ){
$cache = @unserialize(file_get_contents($src) );
$checkpoint = $cache['data'] ['checkpoint'];
flock($f, LOCK_UN);