Reputation: 891
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.
Upvotes: 0
Views: 1151
Reputation: 1745
just sharing my code for the ones using APC. should be quite the same. i just passed the prefix "query" since i was caching a query.
$cache = new sfAPCCache(array('lifetime' => 600, 'prefix' => 'query'));
Upvotes: 0