I'm a beginner in Zend and I'm getting some problems while trying to cache the database query results.
I've read a lot of forums and docs like this http://framework.zend.com/manual/1.12/en/zend.db.table.html (example 31), but all of them generally say to set the $defaultMetadataCache in the construct method.
I did it, but it seems that the cache is not read because I didn't get a better performance.
Here is my construct of file ./library/Zend/Db/Table/Abstract.php
public function __construct($config = array())
{
/**
* Allow a scalar argument to be the Adapter object or Registry key.
*/
if (!is_array($config)) {
$config = array(self::ADAPTER => $config);
}
if ($config) {
$this->setOptions($config);
}
$config_temp = new Zend_Config_Ini(APPLICATION_PATH . '/configs/config.ini', APPLICATION_ENV);
$cache_lifetime = (isset($config_temp->cache->lifetime) && $config_temp->cache->lifetime) ? $config_temp->cache->lifetime : 300;
$cache_dir = (isset($config_temp->cache->dir) && $config_temp->cache->dir) ? $config_temp->cache->dir : '/tmp/hookit/cache/';
if(!is_dir($cache_dir))
mkdir ($cache_dir, 0755, true);
$frontendOptions = array('lifetime' => $cache_lifetime, 'automatic_serialization' => true);
$backendOptions = array('cache_dir' => $cache_dir);
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
if(!self::getDefaultMetadataCache()){
self::setDefaultMetadataCache($cache);
}
$this->_setup();
$this->init();
}