Bug #23402 » 15497_01.diff
t3lib/cache/backend/class.t3lib_cache_backend_memcachedbackend.php (working copy) | ||
---|---|---|
* xxx is identifier, value is array of associated tags. This is "reverse" tag
|
||
* index. It provides quick access for all tags associated with this identifier
|
||
* and used when removing the identifier
|
||
* - tagIndex
|
||
* Value is a List of all tags (array)
|
||
*
|
||
* Each key is prepended with a prefix. By default prefix consists from two parts
|
||
* separated by underscore character and ends in yet another underscore character:
|
||
* - "TYPO3"
|
||
... | ... | |
if ($success === TRUE) {
|
||
$this->removeIdentifierFromAllTags($entryIdentifier);
|
||
$this->addTagsToTagIndex($tags);
|
||
$this->addIdentifierToTags($entryIdentifier, $tags);
|
||
} else {
|
||
throw new t3lib_cache_Exception(
|
||
... | ... | |
}
|
||
/**
|
||
* Returns an array with all known tags
|
||
*
|
||
* @return array
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
* @internal
|
||
*/
|
||
protected function getTagIndex() {
|
||
$tagIndex = $this->memcache->get($this->identifierPrefix . 'tagIndex');
|
||
return ($tagIndex == false ? array() : (array)$tagIndex);
|
||
}
|
||
/**
|
||
* Saves the tags known to the backend
|
||
*
|
||
* @param array Array of tags
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
* @internal
|
||
*/
|
||
protected function setTagIndex(array $tags) {
|
||
$this->memcache->set($this->identifierPrefix . 'tagIndex', array_unique($tags), 0, 0);
|
||
}
|
||
/**
|
||
* Adds the given tags to the tag index
|
||
*
|
||
* @param array Array of tags
|
||
* @return void
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
* @internal
|
||
*/
|
||
protected function addTagsToTagIndex(array $tags) {
|
||
if(count($tags)) {
|
||
$this->setTagIndex(array_merge($tags, $this->getTagIndex()));
|
||
}
|
||
}
|
||
/**
|
||
* Removes the given tags from the tag index
|
||
*
|
||
* @param array $tags
|
||
* @return void
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
* @internal
|
||
*/
|
||
protected function removeTagsFromTagIndex(array $tags) {
|
||
if(count($tags)) {
|
||
$this->setTagIndex(array_diff($this->getTagIndex(), $tags));
|
||
}
|
||
}
|
||
/**
|
||
* Associates the identifier with the given tags
|
||
*
|
||
* @param string $entryIdentifier
|
||
... | ... | |
$identifiers
|
||
);
|
||
} else {
|
||
$this->removeTagsFromTagIndex(array($tag));
|
||
$this->memcache->delete($this->identifierPrefix . 'tag_' . $tag);
|
||
}
|
||
}
|
t3lib/cache/backend/class.t3lib_cache_backend_apcbackend.php (working copy) | ||
---|---|---|
* xxx is identifier, value is array of associated tags. This is "reverse" tag
|
||
* index. It provides quick access for all tags associated with this identifier
|
||
* and used when removing the identifier
|
||
* - tagIndex
|
||
* Value is a List of all tags (array)
|
||
*
|
||
* Each key is prepended with a prefix. By default prefix consists from two parts
|
||
* separated by underscore character and ends in yet another underscore character:
|
||
* - "TYPO3"
|
||
... | ... | |
$success = apc_store($this->identifierPrefix . $entryIdentifier, $data, $expiration);
|
||
if ($success === TRUE) {
|
||
$this->removeIdentifierFromAllTags($entryIdentifier);
|
||
$this->addTagsToTagIndex($tags);
|
||
$this->addIdentifierToTags($entryIdentifier, $tags);
|
||
} else {
|
||
throw new t3lib_cache_Exception(
|
||
... | ... | |
}
|
||
/**
|
||
* Returns an array with all known tags
|
||
*
|
||
* @return array
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
*/
|
||
protected function getTagIndex() {
|
||
$success = FALSE;
|
||
$tagIndex = apc_fetch($this->identifierPrefix . 'tagIndex', $success);
|
||
return ($success ? (array)$tagIndex : array());
|
||
}
|
||
/**
|
||
* Saves the tags known to the backend
|
||
*
|
||
* @param array $tags
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
*/
|
||
protected function setTagIndex(array $tags) {
|
||
apc_store($this->identifierPrefix . 'tagIndex', array_unique($tags));
|
||
}
|
||
/**
|
||
* Adds the given tags to the tag index
|
||
*
|
||
* @param array $tags
|
||
* @return void
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
*/
|
||
protected function addTagsToTagIndex(array $tags) {
|
||
if (count($tags)) {
|
||
$this->setTagIndex(array_merge($tags, $this->getTagIndex()));
|
||
}
|
||
}
|
||
/**
|
||
* Removes the given tags from the tag index
|
||
*
|
||
* @param array $tags
|
||
* @return void
|
||
* @author Karsten Dambekalns <karsten@typo3.org>
|
||
*/
|
||
protected function removeTagsFromTagIndex(array $tags) {
|
||
if (count($tags)) {
|
||
$this->setTagIndex(array_diff($this->getTagIndex(), $tags));
|
||
}
|
||
}
|
||
/**
|
||
* Associates the identifier with the given tags
|
||
*
|
||
* @param string $entryIdentifier
|
||
... | ... | |
if (count($identifiers)) {
|
||
apc_store($this->identifierPrefix . 'tag_' . $tag, $identifiers);
|
||
} else {
|
||
$this->removeTagsFromTagIndex(array($tag));
|
||
apc_delete($this->identifierPrefix . 'tag_' . $tag);
|
||
}
|
||
}
|
- « Previous
- 1
- 2
- 3
- Next »