当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Cache::_makeBackend方法代码示例

本文整理汇总了PHP中Zend_Cache::_makeBackend方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Cache::_makeBackend方法的具体用法?PHP Zend_Cache::_makeBackend怎么用?PHP Zend_Cache::_makeBackend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Cache的用法示例。


在下文中一共展示了Zend_Cache::_makeBackend方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createBackend

 /**
  * @param $backend
  * @param $backendOptions
  * @return \Zend_Cache_Backend
  */
 private function createBackend($backend, $backendOptions)
 {
     if (strtolower($backend) === 'auto') {
         $backend = $this->createAutomaticBackend($backendOptions);
     } else {
         $backend = \Zend_Cache::_makeBackend($backend, $backendOptions);
     }
     return $backend;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:14,代码来源:Cache.php

示例2: __construct

 /**
  * Constructor
  *
  * @param  array $options Associative array of options
  * @throws Zend_Cache_Exception
  * @return void
  */
 public function __construct(array $options = array())
 {
     parent::__construct($options);
     if ($this->_options['slow_backend'] === null) {
         Zend_Cache::throwException('slow_backend option has to set');
     } elseif ($this->_options['slow_backend'] instanceof Zend_Cache_Backend_ExtendedInterface) {
         $this->_slowBackend = $this->_options['slow_backend'];
     } else {
         $this->_slowBackend = Zend_Cache::_makeBackend($this->_options['slow_backend'], $this->_options['slow_backend_options'], $this->_options['slow_backend_custom_naming'], $this->_options['slow_backend_autoload']);
         if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_slowBackend))) {
             Zend_Cache::throwException('slow_backend must implement the Zend_Cache_Backend_ExtendedInterface interface');
         }
     }
     if ($this->_options['fast_backend'] === null) {
         Zend_Cache::throwException('fast_backend option has to set');
     } elseif ($this->_options['fast_backend'] instanceof Zend_Cache_Backend_ExtendedInterface) {
         $this->_fastBackend = $this->_options['fast_backend'];
     } else {
         $this->_fastBackend = Zend_Cache::_makeBackend($this->_options['fast_backend'], $this->_options['fast_backend_options'], $this->_options['fast_backend_custom_naming'], $this->_options['fast_backend_autoload']);
         if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_fastBackend))) {
             Zend_Cache::throwException('fast_backend must implement the Zend_Cache_Backend_ExtendedInterface interface');
         }
     }
     $this->_slowBackend->setDirectives($this->_directives);
     $this->_fastBackend->setDirectives($this->_directives);
 }
开发者ID:netvlies,项目名称:zf,代码行数:33,代码来源:TwoLevels.php

示例3: getCacheBackendService

 public function getCacheBackendService()
 {
     if (!isset($this->services['cacheBackend'])) {
         $fileBackendOptions = array('cache_dir' => DATA_DIR . '/cache');
         if (extension_loaded('xcache') && ini_get('xcache.var_size') > 0) {
             $this->services['cacheBackend'] = Zend_Cache::_makeBackend('Xcache', array());
         } elseif (is_writeable($fileBackendOptions['cache_dir'])) {
             $this->services['cacheBackend'] = Zend_Cache::_makeBackend('two-levels', array('slow_backend' => 'File', 'slow_backend_options' => $fileBackendOptions, 'fast_backend' => new Am_Cache_Backend_Array(), 'auto_refresh_fast_cache' => true));
         } else {
             $this->services['cacheBackend'] = new Am_Cache_Backend_Null();
         }
     }
     return $this->services['cacheBackend'];
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:14,代码来源:Di.php

示例4: getBackends

 public function getBackends()
 {
     if (null === $this->_backends) {
         foreach ($this->_optionTemplates as $key => $value) {
             //Specific Zend cache
             if ($key === 'skeleton' || $key === 'default' || $key === 'pagetag') {
                 continue;
             }
             //Specific Zend cache
             if ($key === 'page') {
                 $this->_backends[$key] = $this->getCache('page')->getBackend();
             } else {
                 if (isset($this->_caches[$key])) {
                     $this->_backends[$key] = $this->_caches[$key]->getBackend();
                 } else {
                     $this->_backends[$key] = Zend_Cache::_makeBackend($value['backend']['name'], $value['backend']['options'], isset($value['backend']['customBackendNaming']) ? $value['backend']['customBackendNaming'] : false);
                 }
             }
         }
     }
     return $this->_backends;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:22,代码来源:Manager.php

示例5: performanceAction

 public function performanceAction()
 {
     $setting_file = APPLICATION_PATH . '/application/settings/cache.php';
     $default_file_path = APPLICATION_PATH . '/temporary/cache';
     if (file_exists($setting_file)) {
         $current_cache = (include $setting_file);
     } else {
         $current_cache = array('default_backend' => 'File', 'frontend' => array('core' => array('automatic_serialization' => true, 'cache_id_prefix' => 'Engine4_', 'lifetime' => '300', 'caching' => true, 'gzip' => 1)), 'backend' => array('File' => array('cache_dir' => APPLICATION_PATH . '/temporary/cache')));
     }
     $current_cache['default_file_path'] = $default_file_path;
     $this->view->form = $form = new Core_Form_Admin_Settings_Performance();
     // pre-fill form with proper cache type
     $form->populate($current_cache);
     // disable caching types not supported
     $disabled_type_options = $removed_type_options = array();
     foreach ($form->getElement('type')->options as $i => $backend) {
         if ('Apc' == $backend && !extension_loaded('apc')) {
             $disabled_type_options[] = $backend;
         }
         if ('Memcached' == $backend && !extension_loaded('memcache')) {
             $disabled_type_options[] = $backend;
         }
         if ('Xcache' == $backend && !extension_loaded('xcache')) {
             $disabled_type_options[] = $backend;
         }
     }
     $form->getElement('type')->setAttrib('disable', $disabled_type_options);
     // set required elements before checking for validity
     switch ($this->getRequest()->getPost('type')) {
         case 'File':
             $form->getElement('file_path')->setRequired(true)->setAllowEmpty(false);
             break;
         case 'Memcached':
             $form->getElement('memcache_host')->setRequired(true)->setAllowEmpty(false);
             $form->getElement('memcache_port')->setRequired(true)->setAllowEmpty(false);
             break;
         case 'Xcache':
             $form->getElement('xcache_username')->setRequired(true)->setAllowEmpty(false);
             $form->getElement('xcache_password')->setRequired(true)->setAllowEmpty(false);
             break;
     }
     if (is_writable($setting_file) || is_writable(dirname($setting_file)) && !file_exists($setting_file)) {
         // do nothing
     } else {
         //if( (is_file($setting_file) && !is_writable($setting_file))
         //    || (!is_file($setting_file) && is_dir(dirname($setting_file)) && !is_writable(dirname($setting_file))) ) {
         $phrase = Zend_Registry::get('Zend_Translate')->_('Changes made to this form will not be saved.  Please adjust the permissions (CHMOD) of file %s to 777 and try again.');
         $form->addError(sprintf($phrase, '/application/settings/cache.php'));
         return;
     }
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         $this->view->isPost = true;
         $code = "<?php\ndefined('_ENGINE') or die('Access Denied');\nreturn ";
         $do_flush = false;
         foreach ($form->getElement('type')->options as $type => $label) {
             if (array_key_exists($type, $current_cache['backend']) && $type != $this->_getParam('type')) {
                 $do_flush = true;
             }
         }
         $options = array();
         switch ($this->getRequest()->getPost('type')) {
             case 'File':
                 $options['file_locking'] = (bool) $this->_getParam('file_locking');
                 $options['cache_dir'] = $this->_getParam('file_path');
                 if (!is_writable($options['cache_dir'])) {
                     $options['cache_dir'] = $default_file_path;
                     $form->getElement('file_path')->setValue($default_file_path);
                 }
                 break;
             case 'Memcached':
                 $options['servers'][] = array('host' => $this->_getParam('memcache_host'), 'port' => (int) $this->_getParam('memcache_port'));
                 $options['compression'] = (bool) $this->_getParam('memcache_compression');
         }
         $current_cache['backend'] = array($this->_getParam('type') => $options);
         $current_cache['frontend']['core']['lifetime'] = $this->_getParam('lifetime');
         $current_cache['frontend']['core']['caching'] = (bool) $this->_getParam('enable');
         $current_cache['frontend']['core']['gzip'] = (bool) $this->_getParam('gzip_html');
         $code .= var_export($current_cache, true);
         $code .= '; ?>';
         // test write+read before saving to file
         $backend = null;
         if (!$current_cache['frontend']['core']['caching']) {
             $this->view->success = true;
         } else {
             $backend = Zend_Cache::_makeBackend($this->_getParam('type'), $options);
             if ($current_cache['frontend']['core']['caching'] && @$backend->save('test_value', 'test_id') && @$backend->test('test_id')) {
                 #$backend->remove('test_id');
                 $this->view->success = true;
             } else {
                 $this->view->success = false;
                 $form->getElement('type')->setErrors(array('Unable to use this backend.  Please check your settings or try another one.'));
             }
         }
         // write settings to file
         if ($this->view->success && file_put_contents($setting_file, $code)) {
             $form->addNotice('Your changes have been saved.');
         } elseif ($this->view->success) {
             $form->addError('Your settings were unable to be saved to the
       cache file.  Please log in through FTP and either CHMOD 777 the file
       <em>/application/settings/cache.php</em>, or edit that file and
//.........这里部分代码省略.........
开发者ID:hoalangoc,项目名称:ftf,代码行数:101,代码来源:AdminSettingsController.php

示例6: performanceAction

 public function performanceAction()
 {
     $setting_file = APPLICATION_PATH . '/application/settings/cache.php';
     $default_file_path = APPLICATION_PATH . '/temporary/cache';
     if (file_exists($setting_file)) {
         $current_cache = (include $setting_file);
     } else {
         $current_cache = array('default_backend' => 'File', 'frontend' => array('core' => array('automatic_serialization' => true, 'cache_id_prefix' => 'Engine4_', 'lifetime' => '300', 'caching' => true)), 'backend' => array('File' => array('cache_dir' => APPLICATION_PATH . '/temporary/cache')));
     }
     $current_cache['default_file_path'] = $default_file_path;
     $this->view->form = $form = new Core_Form_Admin_Settings_Performance();
     // pre-fill form with proper cache type
     $form->populate($current_cache);
     // disable caching types not supported
     $disabled_type_options = $removed_type_options = array();
     foreach ($form->getElement('type')->options as $i => $backend) {
         if ('Apc' == $backend && !extension_loaded('apc')) {
             $disabled_type_options[] = $backend;
         }
         if ('Memcached' == $backend && !extension_loaded('memcache')) {
             $disabled_type_options[] = $backend;
         }
         if ('Xcache' == $backend && !extension_loaded('xcache')) {
             $disabled_type_options[] = $backend;
         }
     }
     $form->getElement('type')->setAttrib('disable', $disabled_type_options);
     // set required elements before checking for validity
     switch ($this->getRequest()->getPost('type')) {
         case 'File':
             $form->getElement('file_path')->setRequired(true)->setAllowEmpty(false);
             break;
         case 'Memcached':
             $form->getElement('memcache_host')->setRequired(true)->setAllowEmpty(false);
             $form->getElement('memcache_port')->setRequired(true)->setAllowEmpty(false);
             break;
         case 'Memcached':
             $form->getElement('xcache_username')->setRequired(true)->setAllowEmpty(false);
             $form->getElement('xcache_password')->setRequired(true)->setAllowEmpty(false);
             break;
     }
     if (is_writable($setting_file) || is_writable(dirname($setting_file)) && !file_exists($setting_file)) {
         // do nothing
     } else {
         //if( (is_file($setting_file) && !is_writable($setting_file))
         //    || (!is_file($setting_file) && is_dir(dirname($setting_file)) && !is_writable(dirname($setting_file))) ) {
         $phrase = Zend_Registry::get('Zend_Translate')->_('Changes made to this form will not be saved.  Please adjust the permissions (CHMOD) of file %s to 777 and try again.');
         $form->addError(sprintf($phrase, '/application/settings/cache.php'));
         return;
     }
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
         $this->view->isPost = true;
         $code = "<?php\ndefined('_ENGINE') or die('Access Denied');\nreturn ";
         $do_flush = false;
         foreach ($form->getElement('type')->options as $type => $label) {
             if (array_key_exists($type, $current_cache['backend']) && $type != $this->_getParam('type')) {
                 $do_flush = true;
             }
         }
         $options = array();
         switch ($this->getRequest()->getPost('type')) {
             case 'File':
                 $options['file_locking'] = (bool) $this->_getParam('file_locking');
                 $options['cache_dir'] = $this->_getParam('file_path');
                 if (!is_writable($options['cache_dir'])) {
                     $options['cache_dir'] = $default_file_path;
                     $form->getElement('file_path')->setValue($default_file_path);
                 }
                 break;
             case 'Memcached':
                 $options['servers'][] = array('host' => $this->_getParam('memcache_host'), 'port' => (int) $this->_getParam('memcache_port'));
                 $options['compression'] = (bool) $this->_getParam('memcache_compression');
         }
         $current_cache['backend'] = array($this->_getParam('type') => $options);
         $current_cache['frontend']['core']['lifetime'] = $this->_getParam('lifetime');
         $current_cache['frontend']['core']['caching'] = (bool) $this->_getParam('enable');
         $code .= var_export($current_cache, true);
         $code .= '; ?>';
         // test write+read before saving to file
         $backend = null;
         if (!$current_cache['frontend']['core']['caching']) {
             $this->view->success = true;
         } else {
             $backend = Zend_Cache::_makeBackend($this->_getParam('type'), $options);
             if ($current_cache['frontend']['core']['caching'] && @$backend->save('test_value', 'test_id') && @$backend->test('test_id')) {
                 #$backend->remove('test_id');
                 $this->view->success = true;
             } else {
                 $this->view->success = false;
                 $form->getElement('type')->setErrors(array('Unable to use this backend.  Please check your settings or try another one.'));
             }
         }
         // write settings to file
         if ($this->view->success && file_put_contents($setting_file, $code)) {
             $form->addNotice('Your changes have been saved.');
         } elseif ($this->view->success) {
             $form->addError('Your settings were unable to be saved to the
       cache file.  Please log in through FTP and either CHMOD 777 the file
       <em>/application/settings/cache.php</em>, or edit that file and
       replace the existing code with the following:<br/>
//.........这里部分代码省略.........
开发者ID:robeendey,项目名称:ce,代码行数:101,代码来源:AdminSettingsController.php


注:本文中的Zend_Cache::_makeBackend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。