protected function SensorRunner::cacheResults in Monitoring 7
Same name and namespace in other branches
- 8 src/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 lib/
Drupal/ monitoring/ SensorRunner.php - Runs the defined sensors.
File
- lib/
Drupal/ monitoring/ SensorRunner.php, line 283 - 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
->getSensorInfo();
if ($definition
->getCachingTime() && !$result
->isCached()) {
$data = array(
'name' => $result
->getSensorName(),
'sensor_status' => $result
->getStatus(),
'sensor_message' => $result
->getMessage(),
'sensor_expected_value' => $result
->getExpectedValue(),
'sensor_value' => $result
->getValue(),
'execution_time' => $result
->getExecutionTime(),
'timestamp' => $result
->getTimestamp(),
);
cache_set($this
->getSensorCid($result
->getSensorName()), $data, 'cache', REQUEST_TIME + $definition
->getCachingTime());
}
}
}