/**
  * @param \RainLoop\Model\Account $oAccount = null
  * @param bool $bForceFile = false
  *
  * @return \MailSo\Cache\CacheClient
  */
 public function Cacher($oAccount = null, $bForceFile = false)
 {
     $sKey = '';
     if ($oAccount) {
         $sKey = $oAccount->ParentEmailHelper();
     }
     $sIndexKey = empty($sKey) ? '_default_' : $sKey;
     if ($bForceFile) {
         $sIndexKey .= '/_files_';
     }
     if (!isset($this->aCachers[$sIndexKey])) {
         $this->aCachers[$sIndexKey] = \MailSo\Cache\CacheClient::NewInstance();
         $oDriver = null;
         $sDriver = \strtoupper(\trim($this->Config()->Get('cache', 'fast_cache_driver', 'files')));
         switch (true) {
             default:
             case $bForceFile:
                 $oDriver = \MailSo\Cache\Drivers\File::NewInstance(APP_PRIVATE_DATA . 'cache', $sKey);
                 break;
             case ('APC' === $sDriver || 'APCU' === $sDriver) && \MailSo\Base\Utils::FunctionExistsAndEnabled(array('apc_store', 'apc_fetch', 'apc_delete', 'apc_clear_cache')):
                 $oDriver = \MailSo\Cache\Drivers\APC::NewInstance($sKey);
                 break;
             case ('MEMCACHE' === $sDriver || 'MEMCACHED' === $sDriver) && \MailSo\Base\Utils::FunctionExistsAndEnabled('memcache_connect'):
                 $oDriver = \MailSo\Cache\Drivers\Memcache::NewInstance($this->Config()->Get('labs', 'fast_cache_memcache_host', '127.0.0.1'), (int) $this->Config()->Get('labs', 'fast_cache_memcache_port', 11211), 43200, $sKey);
                 break;
         }
         if ($oDriver) {
             $this->aCachers[$sIndexKey]->SetDriver($oDriver);
         }
         $this->aCachers[$sIndexKey]->SetCacheIndex($this->Config()->Get('cache', 'fast_cache_index', ''));
     }
     return $this->aCachers[$sIndexKey];
 }
Beispiel #2
0
 /**
  * @return \MailSo\Cache\CacheClient
  */
 public function Cacher()
 {
     if (null === $this->oCacher) {
         $this->oCacher = \MailSo\Cache\CacheClient::NewInstance();
         $oDriver = null;
         $sDriver = \strtoupper(\trim($this->Config()->Get('cache', 'fast_cache_driver', 'files')));
         switch (true) {
             case 'APC' === $sDriver && \MailSo\Base\Utils::FunctionExistsAndEnabled('apc_store'):
                 $oDriver = \MailSo\Cache\Drivers\APC::NewInstance();
                 break;
             case 'MEMCACHE' === $sDriver && \MailSo\Base\Utils::FunctionExistsAndEnabled('memcache_connect'):
             case 'MEMCACHED' === $sDriver && \MailSo\Base\Utils::FunctionExistsAndEnabled('memcache_connect'):
                 $oDriver = \MailSo\Cache\Drivers\Memcache::NewInstance($this->Config()->Get('labs', 'fast_cache_memcache_host', '127.0.0.1'), (int) $this->Config()->Get('labs', 'fast_cache_memcache_port', 11211));
                 break;
             default:
                 $oDriver = \MailSo\Cache\Drivers\File::NewInstance(APP_PRIVATE_DATA . 'cache');
                 break;
         }
         if ($oDriver) {
             $this->oCacher->SetDriver($oDriver);
         }
         $this->oCacher->SetCacheIndex($this->Config()->Get('cache', 'fast_cache_index', ''));
     }
     return $this->oCacher;
 }