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


PHP Cache::throwException方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @param  array $options associative array of options
  * @throws \Zend\Cache\Exception
  */
 public function __construct(array $options = array())
 {
     if (!function_exists('zend_disk_cache_store')) {
         Cache\Cache::throwException('Zend_Cache_ZendServer_Disk backend has to be used within Zend Server environment.');
     }
     parent::__construct($options);
 }
开发者ID:rexmac,项目名称:zf2,代码行数:13,代码来源:Disk.php

示例2: _flush

 /**
  * callback for output buffering
  * (shouldn't really be called manually)
  *
  * @param  string $data Buffered output
  * @return string Data to send to browser
  */
 public function _flush($data)
 {
     $id = array_pop($this->_idStack);
     if (is_null($id)) {
         Cache::throwException('use of _flush() without a start()');
     }
     if ($this->_extension) {
         $this->save(serialize(array($data, $this->_extension)), $id, $this->_tags);
     } else {
         $this->save($data, $id, $this->_tags);
     }
     return $data;
 }
开发者ID:hjr3,项目名称:zf2,代码行数:20,代码来源:Capture.php

示例3: end

 /**
  * Stop the cache
  *
  * @param  array   $tags             Tags array
  * @param  int     $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
  * @param  string  $forcedDatas      If not null, force written datas with this
  * @param  boolean $echoData         If set to true, datas are sent to the browser
  * @param  int     $priority         integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
  * @return void
  */
 public function end($tags = array(), $specificLifetime = false, $forcedDatas = null, $echoData = true, $priority = 8)
 {
     if ($forcedDatas === null) {
         $data = ob_get_contents();
         ob_end_clean();
     } else {
         $data =& $forcedDatas;
     }
     $id = array_pop($this->_idStack);
     if ($id === null) {
         Cache::throwException('use of end() without a start()');
     }
     $this->save($data, $id, $tags, $specificLifetime, $priority);
     if ($echoData) {
         echo $data;
     }
 }
开发者ID:hjr3,项目名称:zf2,代码行数:27,代码来源:Output.php

示例4: _log

 /**
  * Log a message at the WARN (4) priority.
  *
  * @param string $message
  * @throws \Zend\Cache\Exception
  * @return void
  */
 protected function _log($message, $priority = 4)
 {
     if (!$this->_options['logging']) {
         return;
     }
     if (!(isset($this->_options['logger']) || $this->_options['logger'] instanceof Log\Logger)) {
         Cache::throwException('Logging is enabled but logger is not set');
     }
     $logger = $this->_options['logger'];
     $logger->log($message, $priority);
 }
开发者ID:rexmac,项目名称:zf2,代码行数:18,代码来源:Core.php

示例5: clean

 /**
  * Clean some cache records
  *
  * Available modes are :
  * 'all' (default)  => remove all cache entries ($tags is not used)
  * 'old'            => unsupported
  * 'matchingTag'    => unsupported
  * 'notMatchingTag' => unsupported
  * 'matchingAnyTag' => unsupported
  *
  * @param  string $mode clean mode
  * @param  array  $tags array of tags
  * @throws \Zend\Cache\Exception
  * @return boolean true if no problem
  */
 public function clean($mode = Cache\CacheCache\Cache::CLEANING_MODE_ALL, $tags = array())
 {
     switch ($mode) {
         case Cache\Cache::CLEANING_MODE_ALL:
             // Necessary because xcache_clear_cache() need basic authentification
             $backup = array();
             if (isset($_SERVER['PHP_AUTH_USER'])) {
                 $backup['PHP_AUTH_USER'] = $_SERVER['PHP_AUTH_USER'];
             }
             if (isset($_SERVER['PHP_AUTH_PW'])) {
                 $backup['PHP_AUTH_PW'] = $_SERVER['PHP_AUTH_PW'];
             }
             if ($this->_options['user']) {
                 $_SERVER['PHP_AUTH_USER'] = $this->_options['user'];
             }
             if ($this->_options['password']) {
                 $_SERVER['PHP_AUTH_PW'] = $this->_options['password'];
             }
             xcache_clear_cache(XC_TYPE_VAR, 0);
             if (isset($backup['PHP_AUTH_USER'])) {
                 $_SERVER['PHP_AUTH_USER'] = $backup['PHP_AUTH_USER'];
                 $_SERVER['PHP_AUTH_PW'] = $backup['PHP_AUTH_PW'];
             }
             return true;
             break;
         case Cache\Cache::CLEANING_MODE_OLD:
             $this->_log("Zend_Cache_Backend_Xcache::clean() : CLEANING_MODE_OLD is unsupported by the Xcache backend");
             break;
         case Cache\Cache::CLEANING_MODE_MATCHING_TAG:
         case Cache\Cache::CLEANING_MODE_NOT_MATCHING_TAG:
         case Cache\Cache::CLEANING_MODE_MATCHING_ANY_TAG:
             $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_XCACHE_BACKEND);
             break;
         default:
             Cache\Cache::throwException('Invalid mode for clean() method');
             break;
     }
 }
开发者ID:rexmac,项目名称:zf2,代码行数:53,代码来源:Xcache.php

示例6: setMasterFiles

 /**
  * Change the master_file option
  *
  * @param string $masterFile the complete path and name of the master file
  */
 public function setMasterFiles($masterFiles)
 {
     clearstatcache();
     $this->_specificOptions['master_file'] = $masterFiles[0];
     // to keep a compatibility
     $this->_specificOptions['master_files'] = $masterFiles;
     $this->_masterFile_mtimes = array();
     $i = 0;
     foreach ($masterFiles as $masterFile) {
         $this->_masterFile_mtimes[$i] = @filemtime($masterFile);
         if (!$this->_specificOptions['ignore_missing_master_files'] && !$this->_masterFile_mtimes[$i]) {
             Cache::throwException('Unable to read master_file : ' . $masterFile);
         }
         $i++;
     }
 }
开发者ID:rexmac,项目名称:zf2,代码行数:21,代码来源:File.php

示例7: _hash

 /**
  * Make a control key with the string containing datas
  *
  * @param  string $data        Data
  * @param  string $controlType Type of control 'md5', 'crc32' or 'strlen'
  * @throws \Zend\Cache\Exception
  * @return string Control key
  */
 protected function _hash($data, $controlType)
 {
     switch ($controlType) {
         case 'md5':
             return md5($data);
         case 'crc32':
             return crc32($data);
         case 'strlen':
             return strlen($data);
         case 'adler32':
             return hash('adler32', $data);
         default:
             Cache\Cache::throwException("Incorrect hash function : {$controlType}");
     }
 }
开发者ID:hjr3,项目名称:zf2,代码行数:23,代码来源:File.php

示例8: testThrowMethod

 public function testThrowMethod()
 {
     Cache\Cache::throwException('test');
 }
开发者ID:rexmac,项目名称:zf2,代码行数:4,代码来源:FactoryException.php

示例9: _validateIdOrTag

 /**
  * Validate a cache id or a tag (security, reliable filenames, reserved prefixes...)
  *
  * Throw an exception if a problem is found
  *
  * @param  string $string Cache id or tag
  * @throws \Zend\Cache\Exception
  * @return void
  * @deprecated Not usable until perhaps ZF 2.0
  */
 protected static function _validateIdOrTag($string)
 {
     if (!is_string($string)) {
         Cache\Cache::throwException('Invalid id or tag : must be a string');
     }
     // Internal only checked in Frontend - not here!
     if (substr($string, 0, 9) == 'internal-') {
         return;
     }
     // Validation assumes no query string, fragments or scheme included - only the path
     if (!preg_match('/^(?:\\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*\'()\\[\\]:@&=+$,;])*)?)+$/', $string)) {
         Cache\Cache::throwException("Invalid id or tag '{$string}' : must be a valid URL path");
     }
 }
开发者ID:hjr3,项目名称:zf2,代码行数:24,代码来源:StaticBackend.php

示例10: _log

 /**
  * Log a message at the WARN (4) priority.
  *
  * @param  string $message
  * @throws \Zend\Cache\Exception
  * @return void
  */
 protected function _log($message, $priority = 4)
 {
     if (!$this->_directives['logging']) {
         return;
     }
     if (!isset($this->_directives['logger'])) {
         Cache\Cache::throwException('Logging is enabled but logger is not set.');
     }
     $logger = $this->_directives['logger'];
     if (!$logger instanceof Log\Logger) {
         Cache\Cache::throwException('Logger object is not an instance of Zend_Log class.');
     }
     $logger->log($message, $priority);
 }
开发者ID:rexmac,项目名称:zf2,代码行数:21,代码来源:AbstractBackend.php

示例11: makeId

 /**
  * Make a cache id from the function name and parameters
  *
  * @param  callback $callback A valid callback
  * @param  array    $args     Function parameters
  * @throws \Zend\Cache\Exception
  * @return string Cache id
  */
 public function makeId($callback, array $args = array())
 {
     if (!is_callable($callback, true, $name)) {
         Cache::throwException('Invalid callback');
     }
     // functions, methods and classnames are case-insensitive
     $name = strtolower($name);
     // generate a unique id for object callbacks
     if (is_object($callback)) {
         // Closures & __invoke
         $object = $callback;
     } elseif (isset($callback[0])) {
         // array($object, 'method')
         $object = $callback[0];
     }
     if (isset($object)) {
         try {
             $tmp = @serialize($callback);
         } catch (\Exception $e) {
             Cache::throwException($e->getMessage());
         }
         if (!$tmp) {
             $lastErr = error_get_last();
             Cache::throwException("Can't serialize callback object to generate id: {$lastErr['message']}");
         }
         $name .= '__' . $tmp;
     }
     // generate a unique id for arguments
     $argsStr = '';
     if ($args) {
         try {
             $argsStr = @serialize(array_values($args));
         } catch (\Exception $e) {
             Cache::throwException($e->getMessage());
         }
         if (!$argsStr) {
             $lastErr = error_get_last();
             throw Cache::throwException("Can't serialize arguments to generate id: {$lastErr['message']}");
         }
     }
     return md5($name . $argsStr);
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:50,代码来源:FunctionFrontend.php

示例12: _setRegexps

 /**
  * Specific setter for the 'regexps' option (with some additional tests)
  *
  * @param  array $options Associative array
  * @throws \Zend\Cache\Exception
  * @return void
  */
 protected function _setRegexps($regexps)
 {
     if (!is_array($regexps)) {
         Cache::throwException('regexps option must be an array !');
     }
     foreach ($regexps as $regexp => $conf) {
         if (!is_array($conf)) {
             Cache::throwException('regexps option must be an array of arrays !');
         }
         $validKeys = array_keys($this->_specificOptions['default_options']);
         foreach ($conf as $key => $value) {
             if (!is_string($key)) {
                 Cache::throwException("unknown option [{$key}] !");
             }
             $key = strtolower($key);
             if (!in_array($key, $validKeys)) {
                 unset($regexps[$regexp][$key]);
             }
         }
     }
     $this->setOption('regexps', $regexps);
 }
开发者ID:alab1001101,项目名称:zf2,代码行数:29,代码来源:Page.php

示例13: setCachedEntity

 /**
  * Specific method to set the cachedEntity
  *
  * if set to a class name, we will cache an abstract class and will use only static calls
  * if set to an object, we will cache this object methods
  *
  * @param mixed $cachedEntity
  */
 public function setCachedEntity($cachedEntity)
 {
     if (!is_string($cachedEntity) && !is_object($cachedEntity)) {
         Cache::throwException('cached_entity must be an object or a class name');
     }
     $this->_cachedEntity = $cachedEntity;
     $this->_specificOptions['cached_entity'] = $cachedEntity;
     if (is_string($this->_cachedEntity)) {
         $this->_cachedEntityLabel = $this->_cachedEntity;
     } else {
         $ro = new \ReflectionObject($this->_cachedEntity);
         $this->_cachedEntityLabel = $ro->getName();
     }
 }
开发者ID:rexmac,项目名称:zf2,代码行数:22,代码来源:ClassFrontend.php

示例14: clean

 /**
  * Clean some cache records
  *
  * Available modes are :
  * 'all' (default)  => remove all cache entries ($tags is not used)
  * 'old'            => unsupported
  * 'matchingTag'    => unsupported
  * 'notMatchingTag' => unsupported
  * 'matchingAnyTag' => unsupported
  *
  * @param  string $mode clean mode
  * @param  array  $tags array of tags
  * @throws \Zend\Cache\Exception
  * @return boolean true if no problem
  */
 public function clean($mode = Cache\Cache::CLEANING_MODE_ALL, $tags = array())
 {
     switch ($mode) {
         case Cache\Cache::CLEANING_MODE_ALL:
             $this->_clear();
             return true;
             break;
         case Cache\Cache::CLEANING_MODE_OLD:
             $this->_log("Zend_Cache_Backend_ZendServer::clean() : CLEANING_MODE_OLD is unsupported by the Zend Server backends.");
             break;
         case Cache\Cache::CLEANING_MODE_MATCHING_TAG:
         case Cache\Cache::CLEANING_MODE_NOT_MATCHING_TAG:
         case Cache\Cache::CLEANING_MODE_MATCHING_ANY_TAG:
             $this->_clear();
             $this->_log('Zend_Cache_Backend_ZendServer::clean() : tags are unsupported by the Zend Server backends.');
             break;
         default:
             Cache\Cache::throwException('Invalid mode for clean() method');
             break;
     }
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:36,代码来源:AbstractZendServer.php

示例15: clean

 /**
  * Clean some cache records
  *
  * Available modes are :
  * Zend_Cache::CLEANING_MODE_ALL (default)    => remove all cache entries ($tags is not used)
  * Zend_Cache::CLEANING_MODE_OLD              => remove too old cache entries ($tags is not used)
  * Zend_Cache::CLEANING_MODE_MATCHING_TAG     => remove cache entries matching all given tags
  *                                               ($tags can be an array of strings or a single string)
  * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
  *                                               ($tags can be an array of strings or a single string)
  * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
  *                                               ($tags can be an array of strings or a single string)
  *
  * @param  string $mode Clean mode
  * @param  array  $tags Array of tags
  * @throws \Zend\Cache\Exception
  * @return boolean true if no problem
  */
 public function clean($mode = Cache\CacheCache\Cache::CLEANING_MODE_ALL, $tags = array())
 {
     switch ($mode) {
         case Cache\Cache::CLEANING_MODE_ALL:
             $boolFast = $this->_fastBackend->clean(Cache\Cache::CLEANING_MODE_ALL);
             $boolSlow = $this->_slowBackend->clean(Cache\Cache::CLEANING_MODE_ALL);
             return $boolFast && $boolSlow;
             break;
         case Cache\Cache::CLEANING_MODE_OLD:
             return $this->_slowBackend->clean(Cache\Cache::CLEANING_MODE_OLD);
         case Cache\Cache::CLEANING_MODE_MATCHING_TAG:
             $ids = $this->_slowBackend->getIdsMatchingTags($tags);
             $res = true;
             foreach ($ids as $id) {
                 $bool = $this->remove($id);
                 $res = $res && $bool;
             }
             return $res;
             break;
         case Cache\Cache::CLEANING_MODE_NOT_MATCHING_TAG:
             $ids = $this->_slowBackend->getIdsNotMatchingTags($tags);
             $res = true;
             foreach ($ids as $id) {
                 $bool = $this->remove($id);
                 $res = $res && $bool;
             }
             return $res;
             break;
         case Cache\Cache::CLEANING_MODE_MATCHING_ANY_TAG:
             $ids = $this->_slowBackend->getIdsMatchingAnyTags($tags);
             $res = true;
             foreach ($ids as $id) {
                 $bool = $this->remove($id);
                 $res = $res && $bool;
             }
             return $res;
             break;
         default:
             Cache\Cache::throwException('Invalid mode for clean() method');
             break;
     }
 }
开发者ID:hjr3,项目名称:zf2,代码行数:60,代码来源:TwoLevels.php


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