Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0NL committed Jan 22, 2024
1 parent 8bc58e0 commit caab9cd
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
* Test with PHP 8.2 and 8.3
* Drop support for PHP < 8.1
* Parameter and return type declarations where possible.
* Ignore empty tag lists

2.x
===
Expand Down
6 changes: 5 additions & 1 deletion src/CacheInvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function invalidate(array $headers)
*
* @see TagCapable::tags()
*
* @param array $tags Tags that should be removed/expired from the cache
* @param array $tags Tags that should be removed/expired from the cache. An empty tag list is ignored.
*
* @return $this
*
Expand All @@ -232,6 +232,10 @@ public function invalidateTags(array $tags)
if (!$this->cache instanceof TagCapable) {
throw UnsupportedProxyOperationException::cacheDoesNotImplement('Tags');
}
if (!$tags) {
return $this;
}

$this->cache->invalidateTags($tags);

return $this;
Expand Down
4 changes: 4 additions & 0 deletions src/ProxyClient/Cloudflare.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public function __construct(
*/
public function invalidateTags(array $tags)
{
if (!$tags) {
return $this;
}

$this->queueRequest(
'POST',
sprintf(self::API_ENDPOINT.'/zones/%s/purge_cache', $this->options['zone_identifier']),
Expand Down
4 changes: 4 additions & 0 deletions src/ProxyClient/Fastly.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public function __construct(
*/
public function invalidateTags(array $tags)
{
if (!$tags) {
return $this;
}

$url = sprintf(self::API_ENDPOINT.'/service/%s/purge', $this->options['service_identifier']);
$headers = ['Accept' => 'application/json'];
if (true === $this->options['soft_purge']) {
Expand Down
2 changes: 1 addition & 1 deletion src/ProxyClient/Invalidation/TagCapable.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface TagCapable extends ProxyClient
/**
* Remove/Expire cache objects based on cache tags.
*
* @param array $tags Tags that should be removed/expired from the cache
* @param array $tags Tags that should be removed/expired from the cache. An empty tag list should be ignored.
*
* @return $this
*/
Expand Down
4 changes: 4 additions & 0 deletions src/ProxyClient/MultiplexerClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public function flush()
*/
public function invalidateTags(array $tags)
{
if (!$tags) {
return $this;
}

$this->invoke(TagCapable::class, 'invalidateTags', [$tags]);

return $this;
Expand Down
4 changes: 4 additions & 0 deletions src/ProxyClient/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ protected function configureOptions()

public function invalidateTags(array $tags)
{
if (!$tags) {
return $this;
}

$escapedTags = $this->escapeTags($tags);

$chunkSize = $this->determineTagsPerHeader($escapedTags, ',');
Expand Down

0 comments on commit caab9cd

Please sign in to comment.