Hi all,


I've played around with Zend_Cache and I found out that Zend_Cache only supports some kind of 'general lifetime'.

In real enviroments there is a need for cache-record based ttl's. E.g. we're caching some database queries that almost never need to be updated ( so I would set TTL to e.g. 24 hours). Some other queries should only be cached a couple of minutes or even seconds.

Zend_Cache unfortunately only supports a global lifetime. Of course I could override the $_directives array in that way, each time I would call the Zend_Cache::save:


----
$zendCache->setDirectives(array('lifetime', $desiredTTL));
$zendCache->save($contents, $id);
--

If using the APC backend, that would solve all 'garbage' problems, because APC is garbage collecting expired cache records.

But with the File-backend I would still not be able to delete expired cache records (based on indivdual ttl's).

Would it be a good idea to store the desired TTL-value e.g. in the file name. Maybe the cache file could be named like

 cache_ttl_id   ?

Or even storing the expiry date in the filename

 cache_id_$date
 (where $date would be the YYYYMMDDHHIISS expiry date)

Storing the ttl in the file name could help the _clean function (CLEANING_MODE_OLD) deleting expired records (regardless of the global lifetime) .


?
Greetings
Christian


BTW: What would you suggest to use as Backend if APC and memcached both are available? Or would you sill use File-Backend e.g. on a RAM-disk?




Reply via email to