2 namespace TYPO3\CMS\Core\Cache\Backend;
55 if (!extension_loaded(
'wincache')) {
56 throw new \TYPO3\CMS\Core\Cache\Exception(
'The PHP extension "wincache" must be installed and loaded in order to use the wincache backend.', 1343331520);
58 parent::__construct(
$context, $options);
73 public function set($entryIdentifier, $data, array $tags = array(), $lifetime = null)
75 if (!$this->cache instanceof \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface) {
76 throw new \TYPO3\CMS\Core\Cache\Exception(
'No cache frontend has been set yet via setCache().', 1343331521);
78 if (!is_string($data)) {
79 throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException(
'The specified data is of type "' . gettype($data) .
'" but a string is expected.', 1343331522);
81 $tags[] =
'%WCBE%' . $this->cache->getIdentifier();
83 $success = wincache_ucache_set($this->identifierPrefix . $entryIdentifier, $data, $expiration);
84 if ($success ===
true) {
88 throw new \TYPO3\CMS\Core\Cache\Exception(
'Could not set value.', 1343331523);
98 public function get($entryIdentifier)
101 $value = wincache_ucache_get($this->identifierPrefix . $entryIdentifier, $success);
102 return $success ? $value : $success;
111 public function has($entryIdentifier)
113 return wincache_ucache_exists($this->identifierPrefix . $entryIdentifier);
124 public function remove($entryIdentifier)
127 return wincache_ucache_delete($this->identifierPrefix . $entryIdentifier);
140 $identifiers = wincache_ucache_get($this->identifierPrefix .
'tag_' . $tag, $success);
141 if ($success ===
false) {
144 return (array)$identifiers;
158 $tags = wincache_ucache_get($this->identifierPrefix .
'ident_' . $identifier, $success);
159 return $success ? (array)$tags : array();
170 if (!$this->cache instanceof \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface) {
171 throw new \TYPO3\CMS\Core\Cache\Exception(
'Yet no cache frontend has been set via setCache().', 1343331524);
173 $this->
flushByTag(
'%WCBE%' . $this->cache->getIdentifier());
186 foreach ($identifiers as $identifier) {
187 $this->
remove($identifier);
202 $existingTagsUpdated =
false;
204 foreach ($tags as $tag) {
207 if (!in_array($entryIdentifier, $identifiers,
true)) {
208 $identifiers[] = $entryIdentifier;
209 wincache_ucache_set($this->identifierPrefix .
'tag_' . $tag, $identifiers);
212 if (!in_array($tag, $existingTags,
true)) {
213 $existingTags[] = $tag;
214 $existingTagsUpdated =
true;
219 if ($existingTagsUpdated) {
220 wincache_ucache_set($this->identifierPrefix .
'ident_' . $entryIdentifier, $existingTags);
235 foreach ($tags as $tag) {
242 if (($key = array_search($entryIdentifier, $identifiers)) !==
false) {
243 unset($identifiers[$key]);
244 if (!empty($identifiers)) {
245 wincache_ucache_set($this->identifierPrefix .
'tag_' . $tag, $identifiers);
247 wincache_ucache_delete($this->identifierPrefix .
'tag_' . $tag);
252 wincache_ucache_delete($this->identifierPrefix .
'ident_' . $entryIdentifier);