class CacheTagsInvalidator in Fastly 8.3
Cache tags invalidator implementation that invalidates Fastly.
Hierarchy
- class \Drupal\fastly\CacheTagsInvalidator implements CacheTagsInvalidatorInterface
Expanded class hierarchy of CacheTagsInvalidator
1 string reference to 'CacheTagsInvalidator'
1 service uses CacheTagsInvalidator
File
- src/
CacheTagsInvalidator.php, line 11
Namespace
Drupal\fastlyView source
class CacheTagsInvalidator implements CacheTagsInvalidatorInterface {
/**
* The Fastly API.
*
* @var \Drupal\fastly\Api
*/
protected $api;
/**
* CacheTagsHash service.
*
* @var \Drupal\fastly\CacheTagsHash
*/
protected $cacheTagsHash;
/**
* Constructs a CacheTagsInvalidator object.
*
* @param \Drupal\fastly\Api $api
* The Fastly API.
* @param \Drupal\fastly\CacheTagsHash $cache_tags_hash
* CacheTagsHash service.
*/
public function __construct(Api $api, CacheTagsHash $cache_tags_hash) {
$this->api = $api;
$this->cacheTagsHash = $cache_tags_hash;
}
/**
* {@inheritdoc}
*/
public function invalidateTags(array $tags) {
// When either an extension (module/theme) is (un)installed, purge
// everything.
if (in_array('config:core.extension', $tags)) {
$this->api
->purgeAll();
return;
}
// Ignore config:fastly.settings.
if (in_array('config:fastly.settings', $tags)) {
return;
}
// Also invalidate the cache tags as hashes, to automatically also work for
// responses that exceed the 16 KB header limit.
$all_tags_and_hashes = $this->cacheTagsHash
->cacheTagsToHashes($tags);
$this->api
->purgeKeys($all_tags_and_hashes);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheTagsInvalidator:: |
protected | property | The Fastly API. | |
CacheTagsInvalidator:: |
protected | property | CacheTagsHash service. | |
CacheTagsInvalidator:: |
public | function |
Marks cache items with any of the specified tags as invalid. Overrides CacheTagsInvalidatorInterface:: |
|
CacheTagsInvalidator:: |
public | function | Constructs a CacheTagsInvalidator object. |