Description

but if the time to load data is longer as the next run of this code than the the data will load and save more than once
To avoid this show the folloging:

if ( !($data=$cache->load($cacheId)) ) {
if ( $cache->test($cacheId, true) ) { // missing second argument -> $doNotTestExpire
// set the expire time to the next 2 minutes
// the next calls will load these data from cache
$cache->updateExpire($cacheId, 120);
}
// -> loading data
// update or creaete the cache
// the next calls will load the current data from cache
$cache->save($data, $cacheId);
}

Comments

Posted by Fabien MARTY (fab) on 2008-08-29T12:54:50.000+0000

just commited into SVN trunk a new method "touch($id, $extendedLifetime)" (for File and Apc backend only, for the moment)