Skip navigation
Help

cache-install.inc

  1. drupal
    1. 6 drupal/includes/cache-install.inc
    2. 7 drupal/includes/cache-install.inc

Provides a stub cache implementation to be used during installation.

Classes

NameDescription
DrupalFakeCacheA stub cache implementation to be used during the installation process.

File

drupal/includes/cache-install.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provides a stub cache implementation to be used during installation.
  5. */
  6. /**
  7. * A stub cache implementation to be used during the installation process.
  8. *
  9. * The stub implementation is needed when database access is not yet available.
  10. * Because Drupal's caching system never requires that cached data be present,
  11. * these stub functions can short-circuit the process and sidestep the need for
  12. * any persistent storage. Obviously, using this cache implementation during
  13. * normal operations would have a negative impact on performance.
  14. */
  15. class DrupalFakeCache extends DrupalDatabaseCache implements DrupalCacheInterface {
  16. function get($cid) {
  17. return FALSE;
  18. }
  19. function getMultiple(&$cids) {
  20. return array();
  21. }
  22. function set($cid, $data, $expire = CACHE_PERMANENT) {
  23. }
  24. function clear($cid = NULL, $wildcard = FALSE) {
  25. // If there is a database cache, attempt to clear it whenever possible. The
  26. // reason for doing this is that the database cache can accumulate data
  27. // during installation due to any full bootstraps that may occur at the
  28. // same time (for example, Ajax requests triggered by the installer). If we
  29. // didn't try to clear it whenever this function is called, the data in the
  30. // cache would become stale; for example, the installer sometimes calls
  31. // variable_set(), which updates the {variable} table and then clears the
  32. // cache to make sure that the next page request picks up the new value.
  33. // Not actually clearing the cache here therefore leads old variables to be
  34. // loaded on the first page requests after installation, which can cause
  35. // subtle bugs, some of which would not be fixed unless the site
  36. // administrator cleared the cache manually.
  37. try {
  38. if (class_exists('Database')) {
  39. parent::clear($cid, $wildcard);
  40. }
  41. }
  42. // If the attempt at clearing the cache causes an error, that means that
  43. // either the database connection is not set up yet or the relevant cache
  44. // table in the database has not yet been created, so we can safely do
  45. // nothing here.
  46. catch (Exception $e) {
  47. }
  48. }
  49. function isEmpty() {
  50. return TRUE;
  51. }
  52. }