ZF-2685: adding method to update the expire time of cached data

Description

Currently the load and save process is the following:


if ( !($data=$cache->load($cacheId)) ) {
    // loading data
    $cache->save($data, $cacheId);
}

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

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

can you try it ?

thanks

fixed in SVN trunk

Changing issues in preparation for the 1.7.0 release.