You are here

public function SensorRunner::resetCache in Monitoring 8

Same name and namespace in other branches
  1. 7 lib/Drupal/monitoring/SensorRunner.php \Drupal\monitoring\SensorRunner::resetCache()

Reset sensor result caches.

Parameters

array $sensor_names: (optional) Array of sensors to reset the cache for. An empty array clears all results, which is the default.

File

src/SensorRunner.php, line 337
Contains \Drupal\monitoring\SensorRunner.

Class

SensorRunner
Instantiate and run requested sensors.

Namespace

Drupal\monitoring

Code

public function resetCache(array $sensor_names = array()) {
  if (empty($sensor_names)) {

    // No sensor names provided, clear all caches.
    Cache::invalidateTags(array(
      'monitoring_sensor_result',
    ));
  }
  else {
    $cids = array();
    foreach ($sensor_names as $sensor_name) {
      $cids[] = $this
        ->getSensorCid($sensor_name);
    }
    $this->cache
      ->deleteMultiple($cids);
  }
}