public static function _getSlowCache() { static $ret; if (!isset($ret)) { $ret = new Zend_Cache_Core(array('lifetime' => null, 'automatic_serialization' => true, 'automatic_cleaning_factor' => 0, 'write_control' => false)); $ret->setBackend(new Zend_Cache_Backend_File(array('cache_dir' => 'cache/assets', 'cache_file_perm' => 0666, 'hashed_directory_perm' => 0777, 'hashed_directory_level' => 2))); } return $ret; }
private function _getSecondLevelCache() { if (!$this->_secondLevelCache) { $c = new Zend_Cache_Core(array('lifetime' => null, 'write_control' => false, 'automatic_cleaning_factor' => 0, 'automatic_serialization' => true)); $c->setBackend(new Kwf_Cache_Backend_File(array('cache_dir' => 'cache/mediameta', 'hashed_directory_level' => 2))); $this->_secondLevelCache = $c; } return $this->_secondLevelCache; }
private static function _getCache() { static $cache; if (!isset($cache)) { $cache = new Zend_Cache_Core(array('lifetime' => null, 'write_control' => false, 'automatic_cleaning_factor' => 0, 'automatic_serialization' => true)); $cache->setBackend(new Kwf_Cache_Backend_File(array('cache_dir' => 'cache/commonjs', 'hashed_directory_level' => 2))); } return $cache; }
/** * Returns a caching instance. * * @return Zend_Cache_Core */ public function getCache() { if (null === $this->_cache) { $options = $this->getConfig()->cache->frontend->toArray(); $options['automatic_serialization'] = TRUE; if (!isset($options['lifetime']) || (int) $options['lifetime'] < 1) { $options['lifetime'] = NULL; } $this->_cache = new Erfurt_Cache_Frontend_ObjectCache($options); $this->_cache->setBackend($this->_getCacheBackend()); } return $this->_cache; }
public function setCache($cache) { if ($cache instanceof Zend_Cache_Core) { $this->_cache = $cache; } else { if ($cache instanceof Zend_Cache_Backend_Interface) { $this->_cache = new Zend_Cache_Core(array('cache_id_prefix' => get_class($this))); $this->_cache->setBackend($cache); } else { throw new Engine_Package_Manager_Exception('Invalid argument'); } } return $this; }
/** * @description create default cache core * @param string|array $env * @return Zend_Cache_Core * @author Se# * @version 0.0.2 */ protected function _defaultConfigCache($env) { $env = is_array($env) ? $env : array($env); $configCache = null; //We will cache only in defined environment(s) if (in_array(APPLICATION_ENV, $env)) { list($class, $file) = $this->_defineCacheClassAndFile(); // Bubble-defining if (is_file($file)) { require_once 'Zend/Cache.php'; require_once 'Zend/Cache/Core.php'; require_once $file; $configCache = new Zend_Cache_Core(array('automatic_serialization' => true)); $backend = new $class(); $configCache->setBackend($backend); } } return $configCache; }
public function setUp() { $zendCacheCore = new \Zend_Cache_Core(); $zendCacheCore->setBackend(new \Zend_Cache_Backend_BlackHole()); $frontendCache = $this->getMockForAbstractClass('Magento\\Framework\\Cache\\FrontendInterface', [], '', false); $frontendCache->expects($this->any())->method('getLowLevelFrontend')->will($this->returnValue($zendCacheCore)); $cache = $this->getMock('Magento\\Framework\\App\\CacheInterface'); $cache->expects($this->any())->method('getFrontend')->will($this->returnValue($frontendCache)); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $localeResolver = $this->getMock('\\Magento\\Framework\\Locale\\ResolverInterface'); $localeResolver->expects($this->any())->method('getLocale')->willReturn(Resolver::DEFAULT_LOCALE); $timezone = $objectManager->getObject('Magento\\Framework\\Stdlib\\DateTime\\Timezone', ['localeResolver' => $localeResolver]); $context = $this->getMock('Magento\\Framework\\View\\Element\\Template\\Context', [], [], '', false); $context->expects($this->any())->method('getLocaleDate')->will($this->returnValue($timezone)); $this->attribute = $this->getMockBuilder('\\Magento\\Customer\\Api\\Data\\AttributeMetadataInterface')->getMockForAbstractClass(); $this->customerMetadata = $this->getMockBuilder('\\Magento\\Customer\\Api\\CustomerMetadataInterface')->getMockForAbstractClass(); $this->customerMetadata->expects($this->any())->method('getAttributeMetadata')->will($this->returnValue($this->attribute)); date_default_timezone_set('America/Los_Angeles'); $this->_block = new \Magento\Customer\Block\Widget\Dob($context, $this->getMock('Magento\\Customer\\Helper\\Address', [], [], '', false), $this->customerMetadata, $this->getMock('Magento\\Framework\\View\\Element\\Html\\Date', [], [], '', false)); }
public function setUp() { $zendCacheCore = new \Zend_Cache_Core(); $zendCacheCore->setBackend(new \Zend_Cache_Backend_BlackHole()); $frontendCache = $this->getMockForAbstractClass('Magento\\Framework\\Cache\\FrontendInterface', array(), '', false); $frontendCache->expects($this->any())->method('getLowLevelFrontend')->will($this->returnValue($zendCacheCore)); $cache = $this->getMock('Magento\\Framework\\App\\CacheInterface'); $cache->expects($this->any())->method('getFrontend')->will($this->returnValue($frontendCache)); $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $locale = $objectManager->getObject('\\Magento\\Framework\\Locale', array('locale' => \Magento\Framework\Locale\ResolverInterface::DEFAULT_LOCALE)); $localeResolver = $this->getMock('\\Magento\\Framework\\Locale\\ResolverInterface'); $localeResolver->expects($this->any())->method('getLocale')->will($this->returnValue($locale)); $timezone = $objectManager->getObject('\\Magento\\Framework\\Stdlib\\DateTime\\Timezone', array('localeResolver' => $localeResolver)); $context = $this->getMock('Magento\\Framework\\View\\Element\\Template\\Context', array(), array(), '', false); $context->expects($this->any())->method('getLocaleDate')->will($this->returnValue($timezone)); $this->_attribute = $this->getMock('Magento\\Customer\\Service\\V1\\Data\\Eav\\AttributeMetadata', array(), array(), '', false); $this->_metadataService = $this->getMockForAbstractClass('Magento\\Customer\\Service\\V1\\CustomerMetadataServiceInterface', array(), '', false); $this->_metadataService->expects($this->any())->method('getCustomerAttributeMetadata')->will($this->returnValue($this->_attribute)); date_default_timezone_set('America/Los_Angeles'); $this->_block = new Dob($context, $this->getMock('Magento\\Customer\\Helper\\Address', array(), array(), '', false), $this->_metadataService); }
/** * Get options * * @return array */ private function _getOptions() { if (!extension_loaded('apc')) { return $this->_makeOptions(); } //@todo GET SESSION/CACHE/LOAD Config include_once 'ZLayer/Cache.php'; include_once 'Zend/Cache.php'; include_once 'Zend/Cache/Core.php'; include_once 'Zend/Cache/Backend/Apc.php'; $configCache = new Zend_Cache_Core(array('automatic_serialization' => true)); $backend = new Zend_Cache_Backend_Apc(); $configCache->setBackend($backend); //$configMTime = filemtime($file); $cacheId = ZLayer_Cache::id("application"); $configCache->remove($cacheId); if ($configCache->test($cacheId) !== false) { return $configCache->load($cacheId, true); } else { $array = $this->_makeOptions(); $configCache->save($array, $cacheId, array(), null); return $array; } }
/** * Set the backend * * @param \Zend_Cache_Backend $backendObject * @return void */ public function setBackend(\Zend_Cache_Backend $backendObject) { $backendObject = $this->_decorateBackend($backendObject); parent::setBackend($backendObject); }
<?php define("APPLICATION_PATH", realpath(__DIR__)); define("LIBRARY_PATH", realpath(APPLICATION_PATH . "/../library")); require __DIR__ . "/configs/Environment.php.dist"; set_include_path(implode(PATH_SEPARATOR, array(EXTERNAL_LIBRARY_PATH, LIBRARY_PATH, get_include_path()))); require EXTERNAL_LIBRARY_PATH . '/Zend/Loader/Autoloader.php'; Zend_Loader_Autoloader::getInstance()->registerNamespace('Ml_'); $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH, 'namespace' => 'Ml')); $resourceLoader->addResourceType('form', 'forms/', 'Form')->addResourceType('models', 'models/Ml/', 'Model')->addResourceType('resources', 'resources/', 'Resource'); require EXTERNAL_LIBRARY_PATH . '/Zend/Registry.php'; require EXTERNAL_LIBRARY_PATH . '/Zend/Cache/Core.php'; //@todo redo the library/Ml/RouteModule.php the proper way /** Ml_Application */ require EXTERNAL_LIBRARY_PATH . '/Zend/Application.php'; require LIBRARY_PATH . '/Ml/Application.php'; $sysCache = new Zend_Cache_Core(array('automatic_serialization' => true)); $sysCache->setBackend(new Zend_Cache_Backend_File(array("cache_dir" => CACHE_PATH))); Zend_Registry::getInstance()->set("sysCache", $sysCache); // Create application, bootstrap, and run try { $application = new Ml_Application(APPLICATION_ENV, APPLICATION_CONF_FILE, $sysCache, true); $application->bootstrap()->run(); } catch (Exception $e) { //don't throw it because there's no exception wrapper to treat it new Ml_Model_Exception("Exception: " . $e->getMessage(), $e->getCode(), $e); }