58 if (!extension_loaded(
'xcache')) {
60 'The PHP extension "xcache" must be installed and loaded in order to use the xcache backend.',
64 parent::__construct(
$context, $options);
78 public function set($entryIdentifier, $data, array $tags = array(), $lifetime = NULL) {
82 if (!$this->cache instanceof \
TYPO3\CMS\Core\
Cache\Frontend\FrontendInterface) {
84 'No cache frontend has been set yet via setCache().',
88 if (!is_string($data)) {
89 throw new Exception\InvalidDataException(
90 'The specified data is of type "' . gettype($data) .
'" but a string is expected.',
94 $tags[] =
'%XCBE%' . $this->cache->getIdentifier();
96 $success = xcache_set($this->identifierPrefix . $entryIdentifier, $data, $expiration);
97 if ($success === TRUE) {
102 'Could not set value.',
114 public function get($entryIdentifier) {
118 $value = xcache_get($this->identifierPrefix . $entryIdentifier);
119 return $value ?: FALSE;
128 public function has($entryIdentifier) {
132 return xcache_isset($this->identifierPrefix . $entryIdentifier);
143 public function remove($entryIdentifier) {
148 return xcache_unset($this->identifierPrefix . $entryIdentifier);
162 $identifiers = xcache_get($this->identifierPrefix .
'tag_' . $tag);
163 return $identifiers ?: array();
177 $tags = xcache_get($this->identifierPrefix .
'ident_' . $identifier);
178 return $tags ?: array();
191 if (!$this->cache instanceof \
TYPO3\CMS\Core\
Cache\Frontend\FrontendInterface) {
193 'Yet no cache frontend has been set via setCache().',
197 $this->
flushByTag(
'%XCBE%' . $this->cache->getIdentifier());
209 foreach ($identifiers as $identifier) {
210 $this->
remove($identifier);
228 $existingTagsUpdated = FALSE;
231 foreach ($tags as $tag) {
234 if (!in_array($entryIdentifier, $identifiers, TRUE)) {
235 $identifiers[] = $entryIdentifier;
236 xcache_set($this->identifierPrefix .
'tag_' . $tag, $identifiers);
239 if (!in_array($tag, $existingTags, TRUE)) {
240 $existingTags[] = $tag;
241 $existingTagsUpdated = TRUE;
246 if ($existingTagsUpdated) {
247 xcache_set($this->identifierPrefix .
'ident_' . $entryIdentifier, $existingTags);
264 foreach ($tags as $tag) {
271 if (($key = array_search($entryIdentifier, $identifiers)) !== FALSE) {
272 unset($identifiers[$key]);
273 if (count($identifiers)) {
274 xcache_set($this->identifierPrefix .
'tag_' . $tag, $identifiers);
276 xcache_unset($this->identifierPrefix .
'tag_' . $tag);
281 xcache_unset($this->identifierPrefix .
'ident_' . $entryIdentifier);
300 $varSize = ini_get(
'xcache.var_size');
301 return php_sapi_name() ===
'cli' || empty($varSize);
findIdentifiersByTag($tag)
__construct($context, array $options=array())
addIdentifierToTags($entryIdentifier, array $tags)
runningFromCliOrWrongConfiguration()
findTagsByIdentifier($identifier)
removeIdentifierFromAllTags($entryIdentifier)