Skip to content

Commit

Permalink
UHF-9978: Interface for CacheTagInvalidator class
Browse files Browse the repository at this point in the history
  • Loading branch information
tuutti committed Apr 17, 2024
1 parent 127d597 commit 86a9fa4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/Cache/CacheTagInvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* A service to invalidate cache tags on all instances.
*/
final class CacheTagInvalidator {
final class CacheTagInvalidator implements CacheTagInvalidatorInterface {

/**
* Constructs a new instance.
Expand All @@ -24,17 +24,9 @@ public function __construct(
}

/**
* Invalidates given cache tags.
*
* @param array $tags
* An array of cache tags.
* @param array $instances
* The instances to flush caches from.
*
* @return $this
* The self.
* {@inheritdoc}
*/
public function invalidateTags(array $tags, array $instances = []) : self {
public function invalidateTags(array $tags, array $instances = []) : void {
try {
$this->pubSubManager->sendMessage([
'tags' => $tags,
Expand All @@ -43,7 +35,6 @@ public function invalidateTags(array $tags, array $instances = []) : self {
}
catch (ConnectionException) {
}
return $this;
}

}
25 changes: 25 additions & 0 deletions src/Cache/CacheTagInvalidatorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Drupal\helfi_api_base\Cache;

/**
* A service to invalidate cache tags on all instances.
*/
interface CacheTagInvalidatorInterface {

/**
* Invalidates given cache tags.
*
* @param array $tags
* An array of cache tags.
* @param array $instances
* The instances to flush caches from.
*/
public function invalidateTags(
array $tags,
array $instances = []
): void;

}

0 comments on commit 86a9fa4

Please sign in to comment.