I am using file cache in symfony to store my data for some time limit.Below is the code i have written.
$c = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir').'/function'));
if ($c->has('myarray')) {
$cached = $c->get('myarray');
if (!empty($cached)) {
$data = unserialize($cached);
}
} else {
foreach($queries as $key => $query) {
foreach ($query->fetchArray() As $result) {
$data[] = $result;
}
}
$c->set('myarray',serialize($data));
}
Can anybody tell how to set time limit for file cache in symfony so that the cache will be automatically destroyed after an hour.
Simply:
$c = new sfFileCache(array(
'cache_dir' => sfConfig::get('sf_cache_dir').'/function',
'lifetime' => 3600
));
See the code to learn about other option from sfCache.