Download & Extend

db table cache_form not grows without getting cleared

Project:Drupal core
Version:6.10
Component:base system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

Hi, I noticed my cache_form table grows without getting truncated.
My cache_lifetime is set to 5minutes. So it should have cleared out when system_cron kicks in every hour.

I looked at system_cron in modules/system.module, which calls cache_clear_all for cache_form

  $core = array('cache', 'cache_block', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu');
  $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
  foreach ($cache_tables as $table) {
    cache_clear_all(NULL, $table);
  }

So then, I dug into the code and looked at includes/cache.inc for cache_clear_all. The code flows into the following block
  if (empty($cid)) {
    if (variable_get('cache_lifetime', 0)) {
      // We store the time in the current user's $user->cache variable which
      // will be saved into the sessions table by sess_write(). We then
      // simulate that the cache was flushed for this user by not returning
      // cached data that was cached before the timestamp.
      $user->cache = time();

      $cache_flush = variable_get('cache_flush', 0);
      if ($cache_flush == 0) {
        // This is the first request to clear the cache, start a timer.
        variable_set('cache_flush', time());
      }
      else if (time() > ($cache_flush + variable_get('cache_lifetime', 0))) {
        // Clear the cache for everyone, cache_flush_delay seconds have
        // passed since the first request to clear the cache.
        db_query("DELETE FROM {". $table ."} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
        variable_set('cache_flush', 0);
      }

Since the second block is called from a loop in the first block of code, the variable_get/ variable_set in the if/ else if blocks, end up locking out subsequent caches in the loop and only the first cache in the loop gets flushed every cache_lifetime.
Should that be more like variable_get("cache_flush_$table", 0) so that we have a cache flush variable for every table?

Comments

#1

Status:active» closed (duplicate)

This looks like a duplicate of #227228: cache_clear_all and cache_get fail to clear caches when Minimum cache lifetime is on.