You are here

public function Cache::isEmpty in MongoDB 7

File

mongodb_cache/mongodb_cache_plugin.php, line 450

Class

Cache
MongoDB cache implementation.

Namespace

Drupal\mongodb_cache

Code

public function isEmpty() {
  try {

    // Faster than findOne().
    $result = !$this->collection
      ->find([], [
      '_id' => 1,
    ])
      ->limit(1)
      ->next();
  } catch (\MongoConnectionException $e) {

    // An unreachable cache is as good as empty.
    $result = TRUE;
    self::notifyException($e);
  }
  return $result;
}