cache.inc

  1. 8.0.x includes/cache.inc
  2. 8.0.x commands/core/drupal/cache.inc
  3. 6.x includes/cache.inc
  4. 7.x includes/cache.inc
  5. 7.x commands/core/drupal/cache.inc
  6. 5.x includes/cache.inc
  7. master commands/core/drupal/cache.inc
  8. master includes/cache.inc

Engine for the cache commands.

Functions

File

commands/core/drupal/cache.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Engine for the cache commands.
  5. */
  6. function _drush_cache_command_get($cid, $bin) {
  7. if (is_null($bin)) {
  8. $bin = _drush_cache_bin_default();
  9. }
  10. return cache_get($cid, $bin);
  11. }
  12. /**
  13. * The default bin.
  14. *
  15. * @return string
  16. */
  17. function _drush_cache_bin_default() {
  18. return 'cache';
  19. }
  20. function _drush_cache_command_set($cid, $data, $bin, $expire, $tags) {
  21. // Convert the "expire" argument to a valid value for Drupal's cache_set().
  22. if (is_null($bin)) {
  23. $bin = _drush_cache_bin_default();
  24. }
  25. if ($expire == 'CACHE_TEMPORARY') {
  26. $expire = CACHE_TEMPORARY;
  27. }
  28. if (!isset($expire) || $expire == 'CACHE_PERMANENT') {
  29. $expire = CACHE_PERMANENT;
  30. }
  31. // D6/D7 don't natively support cache tags.
  32. return cache_set($cid, $data, $bin, $expire);
  33. }
  34. function _drush_cache_clear_types($include_bootstrapped_types) {
  35. $types = array(
  36. 'drush' => 'drush_cache_clear_drush',
  37. 'all' => 'drush_cache_clear_both',
  38. );
  39. if ($include_bootstrapped_types) {
  40. $types += array(
  41. 'theme-registry' => 'drush_cache_clear_theme_registry',
  42. 'menu' => 'menu_rebuild',
  43. 'css-js' => 'drush_cache_clear_css_js',
  44. 'block' => 'drush_cache_clear_block',
  45. 'module-list' => 'drush_get_modules',
  46. 'theme-list' => 'drush_get_themes',
  47. );
  48. }
  49. $drupal_version = drush_drupal_major_version();
  50. if ($drupal_version >= 7) {
  51. $types['registry'] = 'registry_update';
  52. }
  53. elseif ($drupal_version == 6 && function_exists('module_exists') && module_exists('autoload')) {
  54. // TODO: move this to autoload module.
  55. $types['registry'] = 'autoload_registry_update';
  56. }
  57. return $types;
  58. }
  59. function drush_cache_clear_theme_registry() {
  60. if (drush_drupal_major_version() >= 7) {
  61. drupal_theme_rebuild();
  62. }
  63. else {
  64. cache_clear_all('theme_registry', 'cache', TRUE);
  65. }
  66. }
  67. function drush_cache_clear_menu() {
  68. return menu_router_rebuild();
  69. }
  70. function drush_cache_clear_css_js() {
  71. _drupal_flush_css_js();
  72. drupal_clear_css_cache();
  73. drupal_clear_js_cache();
  74. }
  75. /**
  76. * Clear the cache of the block output.
  77. */
  78. function drush_cache_clear_block() {
  79. cache_clear_all(NULL, 'cache_block');
  80. }
  81. /**
  82. * Clear caches internal to Drush core and Drupal.
  83. */
  84. function drush_cache_clear_both() {
  85. drush_cache_clear_drush();
  86. if (drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
  87. drupal_flush_all_caches();
  88. }
  89. }