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. if (drush_drupal_major_version() == 7) {
  49. $types['registry'] = 'registry_update';
  50. }
  51. }
  52. return $types;
  53. }
  54. function drush_cache_clear_theme_registry() {
  55. if (drush_drupal_major_version() >= 7) {
  56. drupal_theme_rebuild();
  57. }
  58. else {
  59. cache_clear_all('theme_registry', 'cache', TRUE);
  60. }
  61. }
  62. function drush_cache_clear_menu() {
  63. return menu_router_rebuild();
  64. }
  65. function drush_cache_clear_css_js() {
  66. _drupal_flush_css_js();
  67. drupal_clear_css_cache();
  68. drupal_clear_js_cache();
  69. }
  70. /**
  71. * Clear the cache of the block output.
  72. */
  73. function drush_cache_clear_block() {
  74. cache_clear_all(NULL, 'cache_block');
  75. }
  76. /**
  77. * Clear caches internal to Drush core and Drupal.
  78. */
  79. function drush_cache_clear_both() {
  80. drush_cache_clear_drush();
  81. if (drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
  82. drupal_flush_all_caches();
  83. }
  84. }