ZF-4684: Custom cache test function
Description
For large project those have huge cache it takes very long time to clean cached data. I want to implement the idea of Zend_Cache_Frontend_File in Zend_Cache_Core, the cache validity will depend on the user defined function. The idea is not to clean all cache data after each modification, but let user defined function choose to cache or not
Example: Lets assume we save data in the following format:
$cacheObject->save($someData, 'news_' . $newsid, array('news', 'english', 'sport'));
function expire_check_function ($expireTime, $cacheId, $tags) {
// here we get last news modification time that taged as sport and check if cache is expired or not
return $newsObject->getLastModification() > $expireTime;
}
Then user defined function will check if cache data is expired or not depeding on cache id and tags
Comments
Posted by Fabien MARTY (fab) on 2008-10-27T11:46:37.000+0000
if you have huge cache, set "automaticCleaningFactor=0" ans do the garbage collection in a separate process (unix shell...)
try also the sqlite backend if you do some cleaning on tags
your idea is good but I won't implement a such thing until 2.0 release (I need big changes and API break to do this in proper way)
Posted by Fabien MARTY (fab) on 2009-07-17T11:03:33.000+0000
change Assignee because I'm inactive now
Posted by Marc Bennewitz (private) (mabe) on 2010-03-01T10:50:51.000+0000
This only works on backends which can read expired data like file and sqlite.
For ZF 2.0 I'm planning the following: Storing the mtime on save instead of mtime + expire time and check the lifetime on load on these backends than you could calculate your expire time by self.
Example: save some data - the frontend calls save on backend with the default lifetime - on backends like file and sqlite the given lifetime will be ignored - on other backends the given lifetime (default) will be used
read some data by set another lifetime as the default - the frontend calls load on backend with the changed lifetime - on backends like file and sqlite the given lifetime will be used to check if expired (mtime+lifetime < now) - on other backends the given lifetime (own) will be ignored
Would this close your problem ?