本文整理汇总了PHP中Zend_Cache::throwException方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Cache::throwException方法的具体用法?PHP Zend_Cache::throwException怎么用?PHP Zend_Cache::throwException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Cache
的用法示例。
在下文中一共展示了Zend_Cache::throwException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Save some data in a cache
*
* @param mixed $data Data to put in cache (can be another type than string if automatic_serialization is on)
* @param string $id Cache id (if not set, the last cache id will be used)
* @param array $tags Cache tags
* @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
* @throws Zend_Cache_Exception
* @return boolean True if no problem
*/
public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8)
{
if (!$this->_options['caching']) {
return true;
}
if ($id === null) {
$id = $this->_lastId;
} else {
$id = $this->_id($id);
}
self::_validateIdOrTag($id);
if (is_resource($data)) {
Zend_Cache::throwException('Data can\'t be a resource as it can\'t be serialized');
}
/*if ($this->_options['ignore_user_abort'])
{
$abort = ignore_user_abort(true);
}*/
$result = $this->_backend->save($data, $id, $tags, $specificLifetime);
/*if ($this->_options['ignore_user_abort'])
{
ignore_user_abort($abort);
}*/
if (!$result) {
// maybe the cache is corrupted, so we remove it !
if ($this->_options['logging']) {
$this->_log(__CLASS__ . '::' . __METHOD__ . '() : impossible to save cache (id=' . $id . ')');
}
$this->remove($id);
return false;
}
return true;
}
示例2: __construct
/**
* Constructor
*
* @param array $options associative array of options
*/
public function __construct($options = array())
{
if (!extension_loaded('apc')) {
Zend_Cache::throwException('The apc extension must be loaded for using this backend !');
}
parent::__construct($options);
}
示例3: __construct
/**
* Constructor
*
* @param array $options associative array of options
* @throws Zend_Cache_Exception
*/
public function __construct(array $options = array())
{
if (!function_exists('zend_shm_cache_store')) {
Zend_Cache::throwException('Zend_Cache_ZendServer_ShMem backend has to be used within Zend Server environment.');
}
parent::__construct($options);
}
示例4: __construct
/**
* Constructor
*
* @param array $options associative array of options
*/
public function __construct($options = array())
{
if (!extension_loaded('memcache')) {
Zend_Cache::throwException('The memcache extension must be loaded for using this backend !');
}
parent::__construct($options);
if (isset($options['servers'])) {
$value = $options['servers'];
if (isset($value['host'])) {
// in this case, $value seems to be a simple associative array (one server only)
$value = array(0 => $value);
// let's transform it into a classical array of associative arrays
}
$this->setOption('servers', $value);
}
$this->_memcache = new Memcache();
foreach ($this->_options['servers'] as $server) {
if (!array_key_exists('persistent', $server)) {
$server['persistent'] = Zend_Cache_Backend_Memcached::DEFAULT_PERSISTENT;
}
if (!array_key_exists('port', $server)) {
$server['port'] = Zend_Cache_Backend_Memcached::DEFAULT_PORT;
}
$this->_memcache->addServer($server['host'], $server['port'], $server['persistent']);
}
}
示例5: setMasterFile
/**
* Change the master_file option
*
* @param string $masterFile the complete path and name of the master file
*/
public function setMasterFile($masterFile)
{
clearstatcache();
$this->_specificOptions['master_file'] = $masterFile;
if (!($this->_masterFile_mtime = @filemtime($masterFile))) {
Zend_Cache::throwException('Unable to read master_file : ' . $masterFile);
}
}
示例6: _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)) {
Zend_Cache::throwException('use of end() without a start()');
}
$this->save($data, $id, $this->_tags);
return $data;
}
示例7: __construct
/**
* Constructor
*
* @param array $options associative array of options
* @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
*/
public function __construct($options = array())
{
if (isset($options['httpConditional'])) {
if ($options['httpConditional']) {
Zend_Cache::throwException('httpConditional is not implemented for the moment !');
}
}
parent::__construct($options);
}
示例8: _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)) {
Zend_Cache::throwException('use of _flush() without a start()');
}
file_put_contents('/var/www/data.dump', $data);
$this->save($data, $id, $this->_tags);
return $data;
}
示例9: __construct
/**
* Constructor
*
* @param array $options associative array of options
* @throws Zend_Cache_Exception
* @return void
*/
public function __construct($options = array())
{
if ($options['backend'] instanceof Zend_Cache_Backend_Interface || $options['backend'] instanceof Tid_Zend_Cache_Backend_Abstract) {
$this->_backend = $options['backend'];
} else {
Zend_Cache::throwException('The backend option is not correctly set!');
}
$this->_id = '__' . get_class($this) . '__';
parent::__construct($options);
}
示例10: __construct
/**
* Constructor
*
* @param array $options associative array of options
* @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
*/
public function __construct($options = array())
{
if (isset($options['httpConditional'])) {
if ($options['httpConditional']) {
Zend_Cache::throwException('httpConditional is not implemented for the moment !');
}
}
while (list($name, $value) = each($options)) {
$this->setOption($name, $value);
}
}
示例11: __construct
/**
* Constructor
*
* @param array $options associative array of options
*/
public function __construct($options = array())
{
while (list($name, $value) = each($options)) {
$this->setOption($name, $value);
}
if (!isset($this->_specificOptions['master_file'])) {
Zend_Cache::throwException('master_file option must be set');
}
clearstatcache();
if (!($this->_masterFile_mtime = @filemtime($this->_specificOptions['master_file']))) {
Zend_Cache::throwException('Unable to read master_file : ' . $this->_specificOptions['master_file']);
}
}
示例12: _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 ($id === null) {
Zend_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;
}
示例13: __construct
/**
* @param array $options
*/
public function __construct(array $options = [])
{
if (array_key_exists('concrete_backend', $options) && $options['concrete_backend'] instanceof \Zend_Cache_Backend_Interface) {
$this->_backend = $options['concrete_backend'];
unset($options['concrete_backend']);
} else {
\Zend_Cache::throwException("'concrete_backend' is not specified or it does not implement 'Zend_Cache_Backend_Interface' interface");
}
foreach ($options as $optionName => $optionValue) {
if (array_key_exists($optionName, $this->_decoratorOptions)) {
$this->_decoratorOptions[$optionName] = $optionValue;
}
}
}
示例14: __construct
/**
* Constructor
*
* @param array $options associative array of options
*/
public function __construct($options = array())
{
if (!isset($options['cachedEntity'])) {
Zend_Cache::throwException('cachedEntity must be set !');
} else {
if (!is_string($options['cachedEntity']) && !is_object($options['cachedEntity'])) {
Zend_Cache::throwException('cachedEntity must be an object or a class name');
}
}
$this->_cachedEntity = $options['cachedEntity'];
while (list($name, $value) = each($options)) {
$this->setOption($name, $value);
}
$this->setOption('automaticSerialization', true);
}
示例15: setOption
/**
* Set an option
*
* @param string $name name of the option
* @param mixed $value value of the option
*/
public function setOption($name, $value)
{
if (is_string($name)) {
if (array_key_exists($name, $this->_options)) {
// This is a Core option
parent::setOptions($name, $value);
return;
}
if (array_key_exists($name, $this->_specificOptions)) {
// This a specic option of this frontend
$this->_specificOptions[$name] = $value;
return;
}
}
Zend_Cache::throwException("Incorrect option name : {$name}");
}