You are here

public function CacheBackendMongodb::invalidateAll in MongoDB 8

Implements Drupal\Core\Cache\CacheBackendInterface::invalidateAll().

Marks all cache items as invalid. Invalid items may be returned in later calls to get(), if the $allow_invalid argument is TRUE.

Overrides CacheBackendInterface::invalidateAll

File

src/CacheBackendMongodb.php, line 319
Definition of Drupal\mongodb/CacheBackendMongodb.

Class

CacheBackendMongodb
Defines MongoDB cache implementation.

Namespace

Drupal\mongodb

Code

public function invalidateAll() {
  try {
    $this->collection
      ->update(array(), array(
      '$set' => array(
        'expire' => new \MongoDate(REQUEST_TIME - 1),
      ),
    ), array(
      'w' => 0,
      'multiple' => TRUE,
    ));
  } catch (\Exception $e) {

    // The database may not be available.
  }
}