I am using memcache module with the following configuration:

  // the path to the memcache.inc file
  $conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';

  // make MemCacheDrupal the default cache class
  $conf['cache_default_class'] = 'MemCacheDrupal';
  $conf['cache_class_form'] = 'DrupalDatabaseCache';

  // declare Memcached servers
  $conf['memcache_servers'] = array(
    'xxx.xxx.xxx.xxx:11211' => 'default',
    'yyy.yyy.yyy.yyy:11211' => 'default'
  );


My problem is that cache_page does not seem to flush on node save.
Here are the details of my tests:

  • Use browser 1 to display node/1 as an anonymous user
  • Use browser 2 to edit node/1 with an authorized account & save the changes => the new version of node 1 is visible
  • Refresh the page on browser 1 => the old version of node 1 is visible
  • Wait until next cron call & refresh the page on browser 1 => the new version of node 1 is visible


I checked the code of the clear() function and when I replace (memcache.inc line 163):

$this->variable_set('cache_content_flush_' . $this->bin, $this->cache_content_flush);

by:

variable_set('cache_content_flush_' . $this->bin, $this->cache_content_flush);

cache_page is flushed after the update of the node.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sdelbosc’s picture

I have investigated a bit on that point and it seems that the custom variable_set() function in the memcache.inc file should use cache_bootstrap bin instead of cache bin when dealing with variables cid.

Below is my suggestion:

    if ($cached = cache_get('variables', 'cache_bootstrap')) {
      $variables = $cached->data;
      $variables[$name] = $value;
      cache_set('variables', $variables, 'cache_bootstrap');
    }
Berdir’s picture

Priority: Major » Critical

Ups, this is my mistake, I incorrectly ported this from D6.

Can you please provide a patch for this change?

Also, a test for this would be awesome. This could either be a direct API test, we'd however need to do the set/clear/load calls on separate page callbacks, in a test module. Or it could be a real use case test, which configures the site to use page caching and then creates, visits, updates and visits again (with another user) to verify that the clearing works.

But, a patch for just a bugfix would be enough as a start.

brianV’s picture

Status: Active » Needs review
FileSize
713 bytes

Attached patch as requested to move this along...

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Thanks folks, committed and pushed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.