Skip to content

Instantly share code, notes, and snippets.

@eminetto
Created December 12, 2011 23:03
Show Gist options
  • Save eminetto/1469560 to your computer and use it in GitHub Desktop.
Save eminetto/1469560 to your computer and use it in GitHub Desktop.
_initCache
/**
* Inicializa o cache
*
* @return void
* @author Elton Minetto
*/
public function _initCache()
{
$config = Zend_Registry::get('config')->cache;
$frontendOptions = array(
'lifetime' => $config->frontend->lifetime, // tempo de vida
'automatic_serialization' => $config->frontend->automatic_serialization
);
$backendOptions = $config->backend->options->toArray();
// criando uma instancia do cache
$cache = Zend_Cache::factory('Core',//frontend
$config->backend->adapter, //backend
$frontendOptions,
$backendOptions);
/*
* Salva o cache no Registry para ser usado posteriormente
*/
Zend_Registry::set('cache', $cache);
/*
* cache para metadados das tabelas
*/
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment