59 if (!extension_loaded(
'wincache')) {
60 throw new Exception(
'The PHP extension "wincache" must be installed and loaded in order to use the wincache backend.', 1343331520);
76 public function set($entryIdentifier, $data, array $tags = [], $lifetime =
null)
79 throw new Exception(
'No cache frontend has been set yet via setCache().', 1343331521);
81 if (!is_string($data)) {
82 throw new InvalidDataException(
'The specified data is of type "' . gettype($data) .
'" but a string is expected.', 1343331522);
84 $tags[] =
'%WCBE%' . $this->cache->getIdentifier();
86 $success = wincache_ucache_set($this->identifierPrefix . $entryIdentifier, $data, $expiration);
87 if ($success ===
true) {
91 throw new Exception(
'Could not set value.', 1343331523);
101 public function get($entryIdentifier)
104 $value = wincache_ucache_get($this->identifierPrefix . $entryIdentifier, $success);
105 return $success ? $value : $success;
114 public function has($entryIdentifier)
116 return wincache_ucache_exists($this->identifierPrefix . $entryIdentifier);
127 public function remove($entryIdentifier)
130 return wincache_ucache_delete($this->identifierPrefix . $entryIdentifier);
143 $identifiers = wincache_ucache_get($this->identifierPrefix .
'tag_' . $tag, $success);
144 if ($success ===
false) {
147 return (array)$identifiers;
160 $tags = wincache_ucache_get($this->identifierPrefix .
'ident_' . $identifier, $success);
161 return $success ? (array)$tags : [];
172 throw new Exception(
'Yet no cache frontend has been set via setCache().', 1343331524);
174 $this->
flushByTag(
'%WCBE%' . $this->cache->getIdentifier());
186 foreach ($identifiers as $identifier) {
187 $this->
remove($identifier);
201 $existingTagsUpdated =
false;
203 foreach ($tags as $tag) {
206 if (!in_array($entryIdentifier, $identifiers,
true)) {
207 $identifiers[] = $entryIdentifier;
208 wincache_ucache_set($this->identifierPrefix .
'tag_' . $tag, $identifiers);
211 if (!in_array($tag, $existingTags,
true)) {
212 $existingTags[] = $tag;
213 $existingTagsUpdated =
true;
218 if ($existingTagsUpdated) {
219 wincache_ucache_set($this->identifierPrefix .
'ident_' . $entryIdentifier, $existingTags);
233 foreach ($tags as $tag) {
240 if (($key = array_search($entryIdentifier, $identifiers)) !==
false) {
241 unset($identifiers[$key]);
242 if (!empty($identifiers)) {
243 wincache_ucache_set($this->identifierPrefix .
'tag_' . $tag, $identifiers);
245 wincache_ucache_delete($this->identifierPrefix .
'tag_' . $tag);
250 wincache_ucache_delete($this->identifierPrefix .
'ident_' . $entryIdentifier);