Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Enable use of memcache
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Jun 19, 2014
1 parent cfae682 commit 5fc1d3c
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions core/GlobalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,36 +116,41 @@ public function preDispatch()
parent::preDispatch();
if(!$this->isDebug())
{
$frontendOptions = array(
'lifetime' => 86400,
'automatic_serialization' => true
);

$backendOptions = array(
'cache_dir' => UtilityComponent::getCacheDirectory().'/db'
);

$cache = Zend_Cache::factory('Core',
'File',
$frontendOptions,
$backendOptions);

// Passing the object to cache by default
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
$frontendOptions = array('automatic_serialization' => true, 'lifetime' => 86400);
if(extension_loaded('memcache'))
{
$cache = Zend_Cache::factory('Core', 'Memcached', $frontendOptions, array());
}
else if(extension_loaded('memcached'))
{
$cache = Zend_Cache::factory('Core', 'Libmemcached', $frontendOptions, array());
}
else
{
$cacheDir = UtilityComponent::getCacheDirectory() . '/db';
if(is_writable($cacheDir))
{
$backendOptions = array('cache_dir' => $cacheDir);
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
}
}
if(isset($cache))
{
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
}
}
}

/**
* Post-dispatch routines
*
* Common usages for postDispatch() include rendering content in a sitewide
* Common usages for postDispatch() include rendering content in a site wide
* template, link url correction, setting headers, etc.
*
* @return void
*/
public function postDispatch()
{

parent::postDispatch();
if($this->isDebug() && $this->getEnvironment() != 'testing')
{
Expand Down

0 comments on commit 5fc1d3c

Please sign in to comment.