public function PurgersServiceInterface::invalidate in Purge 8.3
Invalidate content from external caches.
Implementations of this method have the responsibility of invalidating the given list of invalidation objects from their external caches. Besides the invalidation itself, it also needs to call ::setState() on each object to reflect the correct state after invalidation.
You can set it to the following states:
- \Drupal\purge\Plugin\Purge\Invalidation\InvStatesInterface::SUCCEEDED
- \Drupal\purge\Plugin\Purge\Invalidation\InvStatesInterface::FAILED
- \Drupal\purge\Plugin\Purge\Invalidation\InvStatesInterface::PROCESSING
- \Drupal\purge\Plugin\Purge\Invalidation\InvStatesInterface::NOT_SUPPORTED
PROCESSING is a special state only intended to be used on caching platforms where more time is required than 1-2 seconds to clear its cache. Usually CDNs with special status API calls where you can later find out if the object succeeded invalidation. When set to this state, the object flows back to the queue to be offered to your plugin again later.
NOT_SUPPORTED will be rarely needed, as invalidation types not listed as supported by your plugin will already be put to this state before it is offered to your plugin by PurgersServiceInterface::invalidate(). However, if there is any technical reason why you couldn't support a particular invalidation at that given time, you can set it as such and it will be offered again later.
Parameters
\Drupal\purge\Plugin\Purge\Processor\ProcessorInterface $processor: The processor plugin that is initiating cache invalidation.
\Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface[] $invalidations: Non-associative array of invalidation objects that each describe what needs to be invalidated by the external caching system. Usually these objects originate from the queue but direct invalidation is also possible, in either cases the behavior of your plugin stays the same.
The number of objects given is dictated by the outer limit of Purge's capacity tracking mechanism and is dynamically calculated. The lower your ::getTimeHint() implementation returns, the more that will be offered at once. However, your real execution time can and should never exceed the defined hint, to protect system stability.
Throws
\Drupal\purge\Plugin\Purge\Purger\Exception\BadBehaviorException Thrown when $invalidations contains other data than derivatives of \Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface.
\Drupal\purge\Plugin\Purge\Purger\Exception\DiagnosticsException Thrown by ::invalidate after a diagnostic of type SEVERITY_ERROR has been detected, which is established after calling DiagnosticsServiceInterface::::isSystemOnFire. Errors by definition force all cache invalidation to be prevented, until the user resolved the issue.
\Drupal\purge\Plugin\Purge\Purger\Exception\CapacityException Thrown when the capacity tracker's global resource limit returns zero or when more $invalidations are given exceeding this limit. Any claimed objects should be released back to the queue (or will expire naturally) and your code should depend on the next processing window.
\Drupal\purge\Plugin\Purge\Purger\Exception\LockException Thrown when other processors are currently busy.
See also
\Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface::setState()
\Drupal\purge\Plugin\Purge\Purger\PurgerCapacityDataInterface::getTimeHint()
1 method overrides PurgersServiceInterface::invalidate()
- PurgersService::invalidate in src/
Plugin/ Purge/ Purger/ PurgersService.php - Invalidate content from external caches.
File
- src/
Plugin/ Purge/ Purger/ PurgersServiceInterface.php, line 135
Class
- PurgersServiceInterface
- Describes a service that distributes access to one or more purgers.
Namespace
Drupal\purge\Plugin\Purge\PurgerCode
public function invalidate(ProcessorInterface $processor, array $invalidations);