public function VarnishPurgerBase::getTimeHint in Varnish purger 8
Same name and namespace in other branches
- 8.2 src/Plugin/Purge/Purger/VarnishPurgerBase.php \Drupal\varnish_purger\Plugin\Purge\Purger\VarnishPurgerBase::getTimeHint()
Get the maximum number of seconds, processing a single invalidation takes.
Implementations need to return the maximum number of seconds it would take them to process a single invalidation. It is important that this value is not smaller than real code will take to execute, but also not many seconds longer then necessary. If - for instance - your purger relies on external HTTP requests, you can set a reasonable request timeout and also use that as estimate here.
General tips:
- The float must stay between 0.1 and 10.00 seconds.
- Always assume that your purger plugin is the only enabled purger.
- Your returning time will be statically cached during request life-time, so don't return different values during a single request.
- If your purger is able to bundle all invalidations in one action, try to estimate the smallest fraction of time per object, e.g.: 0.1.
- If your purger executes invalidation in multiple steps (e.g. some CDNs) that can take many minutes, make sure to keep this value low. Put your objects into PROCESSING and they return back later to check status in which you can finalize their status into SUCCEEDED.
@warning Please take implementing this method seriously, as it strongly influences real-world experiences for end users. Undercutting can result in requests that time out and too high values can lead to queue-processing not being able to keep up.
Return value
float The maximum number of seconds - as a float - it takes you to process.
Overrides PurgerBase::getTimeHint
See also
\Drupal\purge\Plugin\Purge\Purger\CapacityTrackerInterface::getTimeHint()
File
- src/
Plugin/ Purge/ Purger/ VarnishPurgerBase.php, line 152
Class
- VarnishPurgerBase
- Abstract base class for HTTP based configurable purgers.
Namespace
Drupal\varnish_purger\Plugin\Purge\PurgerCode
public function getTimeHint() {
// When runtime measurement is enabled, we just use the base implementation.
if ($this->settings->runtime_measurement) {
return parent::getTimeHint();
}
// Theoretically connection timeouts and general timeouts can add up, so
// we add up our assumption of the worst possible time it takes as well.
return $this->settings->connect_timeout + $this->settings->timeout;
}