4 * Engine for the cache commands.
7 use Drupal\Core\Cache\Cache;
9 function _drush_cache_command_get($cid, $bin) {
11 $bin = _drush_cache_bin_default();
13 return \Drupal::cache($bin)->get($cid);
21 function _drush_cache_bin_default() {
25 function _drush_cache_command_set($cid, $data, $bin, $expire, $tags) {
27 $bin = _drush_cache_bin_default();
30 // Convert the "expire" argument to a valid value for Drupal's cache_set().
31 if ($expire == 'CACHE_TEMPORARY') {
32 $expire = Cache::TEMPORARY;
34 if (!isset($expire) || $expire == 'CACHE_PERMANENT') {
35 $expire = Cache::PERMANENT;
38 return \Drupal::cache($bin)->set($cid, $data, $expire, $tags);
41 function _drush_cache_clear_types($include_bootstrapped_types) {
43 'drush' => 'drush_cache_clear_drush',
45 if ($include_bootstrapped_types) {
47 'theme-registry' => 'drush_cache_clear_theme_registry',
48 'router' => 'drush_cache_clear_router',
49 'css-js' => 'drush_cache_clear_css_js',
50 'module-list' => 'drush_get_modules',
51 'theme-list' => 'drush_get_themes',
52 'render' => 'drush_cache_clear_render',
58 function drush_cache_clear_theme_registry() {
59 \Drupal::service('theme.registry')->reset();
62 function drush_cache_clear_router() {
63 /** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */
64 $router_builder = \Drupal::service('router.builder');
65 $router_builder->rebuild();
68 function drush_cache_clear_css_js() {
69 _drupal_flush_css_js();
70 drupal_clear_css_cache();
71 drupal_clear_js_cache();
75 * Clear the cache of the block output.
77 function drush_cache_clear_block() {
78 // There is no distinct block cache in D8. See https://github.com/drush-ops/drush/issues/1531.
79 // \Drupal::cache('block')->deleteAll();
83 * Clears the render cache entries.
85 function drush_cache_clear_render() {
86 Cache::invalidateTags(['rendered']);