I turned on the query log in devel recently on a site we will be launching soon and I noticed quite a few queries that were "UPDATE cache SET ...." and "SELECT ... FROM CACHE..." I've checked many of these and they are all cache_set($cid,$val,'cache').

I have this in my settings.php:

/**
 * Memcache variables:
 */
$ps_memcache_path        = './sites/all/modules/contrib/memcache/memcache.inc';
$ps_memcache_bins        = array(
  'cache'       => 'default',
  'cache_form'  => 'database',
);
$ps_memcache_dev_servers = array(
  '127.0.0.1:41212' => 'default',
);
$ps_memcache_servers     = array(
  'server:41212' => 'default',
  'server:41212' => 'default',
  'server:41212' => 'default',
);

switch ($env) {
  case 'local':
    break;

  case 'dev':
    $conf['cache_inc']                          = $ps_memcache_path;
    $conf['memcache_key_prefix']                = 'ps_' . $env . '_';
    $conf['memcache_servers']                   = $ps_memcache_dev_servers;
    $conf['memcache_bins']                      = $ps_memcache_bins;
    break;

  case 'stage':
    $conf['cache_inc']                          = $ps_memcache_path;
    $conf['memcache_key_prefix']                = 'ps_' . $env . '_';
    $conf['memcache_servers']                   = $ps_memcache_dev_servers;
    $conf['memcache_bins']                      = $ps_memcache_bins;
    break;

  case 'production':
    $conf['cache_inc']                          = $ps_memcache_path;
    $conf['memcache_key_prefix']                = 'ps_';
    $conf['memcache_servers']                   = $ps_memcache_servers;
    $conf['memcache_bins']                      = $ps_memcache_bins;
    break;
}

Am I missing something? What could I be forgetting?

Comments

bleen’s picture

Here is a sample from my query log ... the "cache_get"s in there that have "preprocess" in the key are explicitly set to use the "cache" table:
Only local images are allowed.
... and my memcaceh bins are barely being used. Something is awry

Only local images are allowed.

catch’s picture

Can you stick a file_put_contents() or a dpm() inside this hunk?


  if (!is_null($table) && isset($bins[$table]) && $bins[$table] == 'database') {
    return _cache_get($cid, $table);
  }

If that's happening with the cache table, then you need to look at the $bins array to see what's going on.

bleen’s picture

@catch:

These are the values I'm seeing in that hunk:

Array (     
  [bins] => Array         (             
    [cache] => default             
    [cache_form] => database        
   )      
  [table] => cache     
  [cid] => preprocess-block
 )

In this case I do NOT enter the if statement (as expected).

bleen’s picture

OK .... somehow the cache_get from /includes/cache.inc is being used ... how is this possible?

bleen’s picture

Status: Active » Closed (works as designed)

I had an error in my settings.php that caused cache_inc to be reset ... blarg!!

Thanks for looking catch

kourosh.a’s picture

Hi, I have the same issue. Could you tell me what was the error in you setting.php ?