Using modelsCache I want to cache common queries in Production, but disable this cache in Development mode. Tried to set Lifetime to 1 second, but queries are still NOT run and delivered from cache. Any ideas why this parameter is totaly ignored?
// Service definition
$di->set('modelsCache', function() use ($config) {
$cacheLifetime = $config->debug ? 1 : 7200; // 2h in Prod, 1 sec in Dev
$frontCache = new \Phalcon\Cache\Frontend\Data(['lifetime' => $cacheLifetime]);
// Dumping $frontCache->getLifetime() gives correctly 1
return new \Phalcon\Cache\Backend\File($frontCache, [
'cacheDir' => $config->site->path->cache . 'queries/'
]);
});
// Example QueryBuilder usage
$this->modelsManager->createBuilder()
...
...
->getQuery()->cache(['key' => $cacheFile])->execute();