Clearing the Drupal caches via Drush is normally done with the cache:rebuild command.
If, however, you've recently installed a third party cache system like memcache or similar then running this command will not clear the Drupal cache tables.
Instead, you'll need to manually clear all of the cache tables using the TRUNCATE SQL command, which means running TRUNCATE against all cache tables in the Drupal database. Normally, you'll see a comment that shows a bunch of commands like this.
TRUNCATE TABLE cache_bootstrap;
TRUNCATE TABLE cache_config;
TRUNCATE TABLE cache_container;
TRUNCATE TABLE cache_data;
TRUNCATE TABLE cache_default;
TRUNCATE TABLE cache_discovery;
TRUNCATE TABLE cache_dynamic_page_cache;
TRUNCATE TABLE cache_entity;
TRUNCATE TABLE cache_menu;
TRUNCATE TABLE cache_render;
TRUNCATE TABLE cache_toolbar;Whilst this is the list of core Drupal tables, there will probably be other tables created by contributed modules that aren't on this list. The list of cache tables is probably different from one site to the other.
Finding those tables and writing the statements for each of them can be a pain.
Here's a Drush command that simplifies this process into a single command.
drush sql:query "SELECT concat('TRUNCATE TABLE ', TABLE_NAME, ';') FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'db' AND TABLE_NAME LIKE '%cache%';"Word of warning, this will clear the caches for all tables in the system that mention the word "cache" in their name. This is meant to pick up any cache tables that might have a database prefix. If you have a random module that stores data in a table that contains the word "cache", but isn't a cache then any data in that table will be deleted. If this happens it's probably a good idea to have a word with the module author as this is not ideal.
Add new comment