Sometimes you wished that all of Drupal cache would be disabled for the sake of testing or any other purpose.
Just call the enable/disable function at will in your custom code. Dont forget to enable caching for production, if you intend to use this in your development
Drupal 7
<?php
function my_module_cache_disable() {
if (!class_exists('DrupalFakeCache')) {
$cache_backends = variable_get('cache_backends', array());
$cache_backends[] = 'includes/cache-install.inc';
variable_set('cache_backends', $cache_backends);
}
// Default to throwing away cache data
variable_set('cache_default_class','DrupalFakeCache');
// Rely on the DB cache for form caching - otherwise forms fail.
variable_set('cache_class_cache_form', 'DrupalDatabaseCache');
}
function my_module_cache_enable() {
// Default to throwing away cache data
variable_del('cache_default_class');
// Rely on the DB cache for form caching - otherwise forms fail.
variable_del('cache_class_cache_form');
}
Drupal 6
function my_module_cache_disable() {
variable_set('cache_inc', './includes/cache-install.inc');
}
function my_module_cache_enable() {
variable_del('cache_inc');
}