identifier = $identifier; $this->backend->setCache($this); } public function getIdentifier(): string { return $this->identifier; } public function getBackend(): BackendInterface { return $this->backend; } public function has(string $entryIdentifier): bool { if (!$this->isValidEntryIdentifier($entryIdentifier)) { throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058486); } return $this->backend->has($entryIdentifier); } public function remove(string $entryIdentifier): bool { if (!$this->isValidEntryIdentifier($entryIdentifier)) { throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233058495); } return $this->backend->remove($entryIdentifier); } public function flush(): void { $this->backend->flush(); } public function flushByTags(array $tags): void { if (!$this->backend instanceof TaggableBackendInterface) { return; } foreach ($tags as $tag) { if (!$this->isValidTag($tag)) { throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233057360); } } $this->backend->flushByTags($tags); } public function flushByTag(string $tag): void { if (!$this->backend instanceof TaggableBackendInterface) { return; } if (!$this->isValidTag($tag)) { throw new \InvalidArgumentException('"' . $tag . '" is not a valid tag for a cache entry.', 1233057359); } $this->backend->flushByTag($tag); } public function collectGarbage(): void { $this->backend->collectGarbage(); } public function isValidEntryIdentifier(string $identifier): bool { return preg_match(self::PATTERN_ENTRYIDENTIFIER, $identifier) === 1; } public function isValidTag(string $tag): bool { return preg_match(self::PATTERN_TAG, $tag) === 1; } }