class InstallBackend

Defines a stub cache implementation to be used during installation.

The stub implementation is needed when database access is not yet available. Because Drupal's caching system never requires that cached data be present, these stub functions can short-circuit the process and sidestep the need for any persistent storage. Obviously, using this cache implementation during normal operations would have a negative impact on performance.

If there is a database cache, this backend will attempt to clear it whenever possible. The reason for doing this is that the database cache can accumulate data during installation due to any full bootstraps that may occur at the same time (for example, Ajax requests triggered by the installer). If we didn't try to clear it whenever one of the delete function are called, the data in the cache would become stale; for example, the installer sometimes calls variable_set(), which updates the {variable} table and then clears the cache to make sure that the next page request picks up the new value. Not actually clearing the cache here therefore leads old variables to be loaded on the first page requests after installation, which can cause subtle bugs, some of which would not be fixed unless the site administrator cleared the cache manually.

Hierarchy

Expanded class hierarchy of InstallBackend

1 file declares its use of InstallBackend
InstallTest.php in drupal/core/modules/system/lib/Drupal/system/Tests/Cache/InstallTest.php
Definition of Drupal\system\Tests\Cache\InstallTest.

File

drupal/core/lib/Drupal/Core/Cache/InstallBackend.php, line 34
Definition of Drupal\Core\Cache\InstallBackend.

Namespace

Drupal\Core\Cache
View source
class InstallBackend extends DatabaseBackend {

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::get().
   */
  public function get($cid, $allow_invalid = FALSE) {
    return FALSE;
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::getMultiple().
   */
  public function getMultiple(&$cids, $allow_invalid = FALSE) {
    return array();
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::set().
   */
  public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::delete().
   */
  public function delete($cid) {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        parent::delete($cid);
      }
    } catch (Exception $e) {
    }
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::deleteMultiple().
   */
  public function deleteMultiple(array $cids) {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        parent::deleteMultiple($cids);
      }
    } catch (Exception $e) {
    }
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::deleteAll().
   */
  public function deleteAll() {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        parent::deleteAll();
      }
    } catch (Exception $e) {
    }
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::deleteExpired().
   */
  public function deleteExpired() {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        parent::deleteExpired();
      }
    } catch (Exception $e) {
    }
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::deleteTags().
   */
  public function deleteTags(array $tags) {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        parent::deleteTags($tags);
      }
    } catch (Exception $e) {
    }
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::invalidate().
   */
  public function invalidate($cid) {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        parent::invalidate($cid);
      }
    } catch (Exception $e) {
    }
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::invalidateMultiple().
   */
  public function invalidateMultiple(array $cids) {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        parent::invalidateMultiple($cids);
      }
    } catch (Exception $e) {
    }
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::invalidateTags().
   */
  public function invalidateTags(array $tags) {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        parent::invalidateTags($tags);
      }
    } catch (Exception $e) {
    }
  }

  /**
   * Implements Drupal\Core\Cache\CacheBackendInterface::invalidateAll().
   */
  public function invalidateAll() {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        parent::invalidateAll($tags);
      }
    } catch (Exception $e) {
    }
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::garbageCollection().
   */
  public function garbageCollection() {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        parent::garbageCollection();
      }
    } catch (Exception $e) {
    }
  }

  /**
   * Overrides Drupal\Core\Cache\DatabaseBackend::isEmpty().
   */
  public function isEmpty() {
    try {
      if (class_exists('Drupal\\Core\\Database\\Database')) {
        return parent::isEmpty();
      }
    } catch (Exception $e) {
    }
    return TRUE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheBackendInterface::CACHE_PERMANENT constant Indicates that the item should never be removed unless explicitly deleted.
DatabaseBackend::$bin protected property
DatabaseBackend::checksumTags protected function Returns the sum total of validations for a given set of tags.
DatabaseBackend::flattenTags protected function 'Flattens' a tags array into an array of strings.
DatabaseBackend::prepareItem protected function Prepares a cached item.
DatabaseBackend::__construct public function Constructs a DatabaseBackend object.
InstallBackend::delete public function Overrides Drupal\Core\Cache\DatabaseBackend::delete(). Overrides DatabaseBackend::delete
InstallBackend::deleteAll public function Overrides Drupal\Core\Cache\DatabaseBackend::deleteAll(). Overrides DatabaseBackend::deleteAll
InstallBackend::deleteExpired public function Overrides Drupal\Core\Cache\DatabaseBackend::deleteExpired(). Overrides DatabaseBackend::deleteExpired
InstallBackend::deleteMultiple public function Overrides Drupal\Core\Cache\DatabaseBackend::deleteMultiple(). Overrides DatabaseBackend::deleteMultiple
InstallBackend::deleteTags public function Overrides Drupal\Core\Cache\DatabaseBackend::deleteTags(). Overrides DatabaseBackend::deleteTags
InstallBackend::garbageCollection public function Overrides Drupal\Core\Cache\DatabaseBackend::garbageCollection(). Overrides DatabaseBackend::garbageCollection
InstallBackend::get public function Overrides Drupal\Core\Cache\DatabaseBackend::get(). Overrides DatabaseBackend::get
InstallBackend::getMultiple public function Overrides Drupal\Core\Cache\DatabaseBackend::getMultiple(). Overrides DatabaseBackend::getMultiple
InstallBackend::invalidate public function Overrides Drupal\Core\Cache\DatabaseBackend::invalidate(). Overrides DatabaseBackend::invalidate
InstallBackend::invalidateAll public function Implements Drupal\Core\Cache\CacheBackendInterface::invalidateAll(). Overrides DatabaseBackend::invalidateAll
InstallBackend::invalidateMultiple public function Overrides Drupal\Core\Cache\DatabaseBackend::invalidateMultiple(). Overrides DatabaseBackend::invalidateMultiple
InstallBackend::invalidateTags public function Overrides Drupal\Core\Cache\DatabaseBackend::invalidateTags(). Overrides DatabaseBackend::invalidateTags
InstallBackend::isEmpty public function Overrides Drupal\Core\Cache\DatabaseBackend::isEmpty(). Overrides DatabaseBackend::isEmpty
InstallBackend::set public function Overrides Drupal\Core\Cache\DatabaseBackend::set(). Overrides DatabaseBackend::set