Zend Cache will help you to prevent the time taken for heavy sql query.
Lines to be added in bootstrap file:
Zend_Loader::loadClass('Cache');
$backend= 'File';$frontend = 'Core';
$frontendOptions= array('lifetime' => 7200);
$backendOptions= array('cache_dir' => 'public/temp');
$cache = Zend_Cache::factory($frontend, $backend,$frontendOptions,$backendOptions);
Zend_Registry::Set('cache',$cache);
Lines to be added in init function of your controller file:
$this->cache = Zend_Registry::get('cache');
Lines to use the Zend Cache:
$data = $this->cache->load('TempVar');
if($data === FALSE)
{
$query=$this->db->query("SELECT * FROM table_name");
$data = $query->fetchAll();
$this->cache->save($data,'UserCompair');
}
$this->view->users = $data
Post a Comment