import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -105,7 +105,7 @@ class Zend_Cache_Core
|
||||
* @var string $_lastId
|
||||
*/
|
||||
private $_lastId = null;
|
||||
|
||||
|
||||
/**
|
||||
* True if the backend implements Zend_Cache_Backend_ExtendedInterface
|
||||
*
|
||||
@ -115,11 +115,11 @@ class Zend_Cache_Core
|
||||
|
||||
/**
|
||||
* Array of capabilities of the backend (only if it implements Zend_Cache_Backend_ExtendedInterface)
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_backendCapabilities = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -156,7 +156,7 @@ class Zend_Cache_Core
|
||||
$this->_extendedBackend = true;
|
||||
$this->_backendCapabilities = $this->_backend->getCapabilities();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,20 +181,20 @@ class Zend_Cache_Core
|
||||
*/
|
||||
public function setOption($name, $value)
|
||||
{
|
||||
if (is_string($name)) {
|
||||
$name = strtolower($name);
|
||||
if (array_key_exists($name, $this->_options)) {
|
||||
// This is a Core option
|
||||
$this->_setOption($name, $value);
|
||||
return;
|
||||
}
|
||||
if (array_key_exists($name, $this->_specificOptions)) {
|
||||
// This a specic option of this frontend
|
||||
$this->_specificOptions[$name] = $value;
|
||||
return;
|
||||
}
|
||||
if (!is_string($name)) {
|
||||
Zend_Cache::throwException("Incorrect option name : $name");
|
||||
}
|
||||
$name = strtolower($name);
|
||||
if (array_key_exists($name, $this->_options)) {
|
||||
// This is a Core option
|
||||
$this->_setOption($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");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -304,7 +304,7 @@ class Zend_Cache_Core
|
||||
* @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)
|
||||
* @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
|
||||
* @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
|
||||
* @throws Zend_Cache_Exception
|
||||
* @return boolean True if no problem
|
||||
*/
|
||||
@ -313,7 +313,7 @@ class Zend_Cache_Core
|
||||
if (!$this->_options['caching']) {
|
||||
return true;
|
||||
}
|
||||
if (is_null($id)) {
|
||||
if ($id === null) {
|
||||
$id = $this->_lastId;
|
||||
} else {
|
||||
$id = $this->_id($id);
|
||||
@ -428,10 +428,10 @@ class Zend_Cache_Core
|
||||
self::_validateTagsArray($tags);
|
||||
return $this->_backend->clean($mode, $tags);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array of stored cache ids which match given tags
|
||||
*
|
||||
*
|
||||
* In case of multiple tags, a logical AND is made between tags
|
||||
*
|
||||
* @param array $tags array of tags
|
||||
@ -447,15 +447,15 @@ class Zend_Cache_Core
|
||||
}
|
||||
return $this->_backend->getIdsMatchingTags($tags);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array of stored cache ids which don't match given tags
|
||||
*
|
||||
*
|
||||
* In case of multiple tags, a logical OR is made between tags
|
||||
*
|
||||
* @param array $tags array of tags
|
||||
* @return array array of not matching cache ids (string)
|
||||
*/
|
||||
*/
|
||||
public function getIdsNotMatchingTags($tags = array())
|
||||
{
|
||||
if (!$this->_extendedBackend) {
|
||||
@ -466,10 +466,10 @@ class Zend_Cache_Core
|
||||
}
|
||||
return $this->_backend->getIdsNotMatchingTags($tags);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array of stored cache ids
|
||||
*
|
||||
*
|
||||
* @return array array of stored cache ids (string)
|
||||
*/
|
||||
public function getIds()
|
||||
@ -477,9 +477,20 @@ class Zend_Cache_Core
|
||||
if (!$this->_extendedBackend) {
|
||||
Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
|
||||
}
|
||||
return $this->_backend->getIds();
|
||||
$array = $this->_backend->getIds();
|
||||
if ((!isset($this->_options['cache_id_prefix'])) || ($this->_options['cache_id_prefix'] == '')) return $array;
|
||||
// we need to remove cache_id_prefix from ids (see #ZF-6178)
|
||||
$res = array();
|
||||
while (list(,$id) = each($array)) {
|
||||
if (strpos($id, $this->_options['cache_id_prefix']) === 0) {
|
||||
$res[] = preg_replace("~^{$this->_options['cache_id_prefix']}~", '', $id);
|
||||
} else {
|
||||
$res[] = $id;
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array of stored tags
|
||||
*
|
||||
@ -493,9 +504,9 @@ class Zend_Cache_Core
|
||||
if (!($this->_backendCapabilities['tags'])) {
|
||||
Zend_Cache::throwException('tags are not supported by the current backend');
|
||||
}
|
||||
return $this->_backend->getTags();
|
||||
return $this->_backend->getTags();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the filling percentage of the backend storage
|
||||
*
|
||||
@ -506,9 +517,9 @@ class Zend_Cache_Core
|
||||
if (!$this->_extendedBackend) {
|
||||
Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
|
||||
}
|
||||
return $this->_backend->getFillingPercentage();
|
||||
return $this->_backend->getFillingPercentage();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Give (if possible) an extra lifetime to the given cache id
|
||||
*
|
||||
@ -521,9 +532,10 @@ class Zend_Cache_Core
|
||||
if (!$this->_extendedBackend) {
|
||||
Zend_Cache::throwException('Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available');
|
||||
}
|
||||
return $this->_backend->touch($id, $extraLifetime);
|
||||
$id = $this->_id($id); // cache id may need prefix
|
||||
return $this->_backend->touch($id, $extraLifetime);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate a cache id or a tag (security, reliable filenames, reserved prefixes...)
|
||||
*
|
||||
@ -533,7 +545,7 @@ class Zend_Cache_Core
|
||||
* @throws Zend_Cache_Exception
|
||||
* @return void
|
||||
*/
|
||||
private static function _validateIdOrTag($string)
|
||||
protected static function _validateIdOrTag($string)
|
||||
{
|
||||
if (!is_string($string)) {
|
||||
Zend_Cache::throwException('Invalid id or tag : must be a string');
|
||||
@ -555,7 +567,7 @@ class Zend_Cache_Core
|
||||
* @throws Zend_Cache_Exception
|
||||
* @return void
|
||||
*/
|
||||
private static function _validateTagsArray($tags)
|
||||
protected static function _validateTagsArray($tags)
|
||||
{
|
||||
if (!is_array($tags)) {
|
||||
Zend_Cache::throwException('Invalid tags array : must be an array');
|
||||
@ -579,17 +591,11 @@ class Zend_Cache_Core
|
||||
if (!isset($this->_options['logging']) || !$this->_options['logging']) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
/**
|
||||
* @see Zend_Log
|
||||
*/
|
||||
require_once 'Zend/Log.php';
|
||||
} catch (Zend_Exception $e) {
|
||||
Zend_Cache::throwException('Logging feature is enabled but the Zend_Log class is not available');
|
||||
}
|
||||
|
||||
if (isset($this->_options['logger']) && $this->_options['logger'] instanceof Zend_Log) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a default logger to the standard output stream
|
||||
require_once 'Zend/Log/Writer/Stream.php';
|
||||
$logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
|
||||
@ -623,9 +629,9 @@ class Zend_Cache_Core
|
||||
* @param string $id Cache id
|
||||
* @return string Cache id (with or without prefix)
|
||||
*/
|
||||
private function _id($id)
|
||||
protected function _id($id)
|
||||
{
|
||||
if (!is_null($id) && isset($this->_options['cache_id_prefix'])) {
|
||||
if (($id !== null) && isset($this->_options['cache_id_prefix'])) {
|
||||
return $this->_options['cache_id_prefix'] . $id; // return with prefix
|
||||
}
|
||||
return $id; // no prefix, just return the $id passed
|
||||
|
Reference in New Issue
Block a user