protected function SensorRunner::cacheResults in Monitoring 8
Same name and namespace in other branches
- 7 lib/Drupal/monitoring/SensorRunner.php \Drupal\monitoring\SensorRunner::cacheResults()
Cache results if caching applies.
Parameters
\Drupal\monitoring\Result\SensorResultInterface[] $results: Results to be cached.
1 call to SensorRunner::cacheResults()
- SensorRunner::runSensors in src/
SensorRunner.php - Runs the defined sensors.
File
- src/
SensorRunner.php, line 273 - Contains \Drupal\monitoring\SensorRunner.
Class
- SensorRunner
- Instantiate and run requested sensors.
Namespace
Drupal\monitoringCode
protected function cacheResults(array $results) {
// @todo: Cache in a single array, with per item expiration?
foreach ($results as $result) {
$definition = $result
->getSensorConfig();
if ($definition
->getCachingTime() && !$result
->isCached()) {
$data = array(
'name' => $result
->getSensorId(),
'sensor_status' => $result
->getStatus(),
'sensor_message' => $result
->getMessage(),
'sensor_expected_value' => $result
->getExpectedValue(),
'sensor_value' => $result
->getValue(),
'execution_time' => $result
->getExecutionTime(),
'timestamp' => $result
->getTimestamp(),
);
$this->cache
->set($this
->getSensorCid($result
->getSensorId()), $data, \Drupal::time()
->getRequestTime() + $definition
->getCachingTime(), array(
'monitoring_sensor_result',
));
}
}
}