diff --git a/helfi_api_base.services.yml b/helfi_api_base.services.yml index 5afde275..b367294f 100644 --- a/helfi_api_base.services.yml +++ b/helfi_api_base.services.yml @@ -150,6 +150,7 @@ services: - '@datetime.time' - '@helfi_api_base.pubsub_settings' + Drupal\helfi_api_base\Cache\CacheTagInvalidatorInterface: '@helfi_api_base.cache_tag_invalidator' Drupal\helfi_api_base\Cache\CacheTagInvalidator: '@helfi_api_base.cache_tag_invalidator' helfi_api_base.cache_tag_invalidator: class: Drupal\helfi_api_base\Cache\CacheTagInvalidator diff --git a/src/Cache/CacheTagInvalidator.php b/src/Cache/CacheTagInvalidator.php index c6987386..ad96c433 100644 --- a/src/Cache/CacheTagInvalidator.php +++ b/src/Cache/CacheTagInvalidator.php @@ -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. @@ -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, @@ -43,7 +35,6 @@ public function invalidateTags(array $tags, array $instances = []) : self { } catch (ConnectionException) { } - return $this; } } diff --git a/src/Cache/CacheTagInvalidatorInterface.php b/src/Cache/CacheTagInvalidatorInterface.php new file mode 100644 index 00000000..840db4a7 --- /dev/null +++ b/src/Cache/CacheTagInvalidatorInterface.php @@ -0,0 +1,25 @@ +