public function __construct() { $this->Path = \CApi::DataPath() . '/sessions'; $oSession = \MailSo\Cache\CacheClient::NewInstance(); $oSessionDriver = \MailSo\Cache\Drivers\File::NewInstance($this->Path); $oSessionDriver->bRootDir = true; $oSession->SetDriver($oSessionDriver); $oSession->SetCacheIndex(\CApi::Version()); $this->Session = $oSession; }
/** * @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]; }
/** * @return \MailSo\Cache\CacheClient */ public static function Cacher() { static $oCacher = null; if (null === $oCacher) { $oCacher = \MailSo\Cache\CacheClient::NewInstance(); $oCacher->SetDriver(\MailSo\Cache\Drivers\File::NewInstance(CApi::DataPath() . '/cache')); $oCacher->SetCacheIndex(self::Version()); } return $oCacher; }
/** * @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; }