Install
Works with Drupal: 7.xUsing Composer to manage Drupal site dependencies
Downloads
Release notes
We had an experience where we constantly needed to clear site cache for over 400 sites at the same time.
Since this is a healthy list of cache to clear, we ran into issues where Drupal would complain about deadlocks on tables.
We traced this to the delete function on cache, which basically used delete per row. This was sucking up most of our resources.
And we love our resources, so I decided to massage the drupal_flush_all_caches function to ALWAYS use truncate instead of using delete.
And to make sure we ALWAYS use Truncate to clear tables, we changed a few lines of code in the function "drupal_flush_all_caches()" from the file located in "includes/common.inc".
Don't panic yet, this is what modules are for, so we can change Drupal core behavior without messing things for everyone.
Truncate is much faster to use than db_delete() because truncate deletes ALL ROWS, leaving the structure and columns intact rather than deleting row by row.
In fact, the function below is similar to drupal_flush_all_caches(), with a few omissions and additions.
We Don't truncate the "cache_form" table because in-progress form submissions may break.
Note that the table "cache_page" is the last table to be truncated.