Using the new memcacheD php module:
http://pecl.php.net/package/memcached
I was getting intermittent PHP warnings like Memcached::add() expects at most 3 parameters, 4 given in dmemcache.inc on line 115.. It appears to be the stampede var being set:
$mc->add($full_key .'_semaphore', '', FALSE, variable_get('memcache_stampede_semaphore', 15))
But digging into it, the issue is a little more troubling:
http://www.php.net/manual/en/memcached.add.php
Indeed it only takes 3 values. Annoyingly, it also appears that the old add() method has a different argument order!
http://www.php.net/manual/en/function.memcache-add.php
It places the compression flag before the expire! Luckily the main dmemcache_add() works around this, but the _get() functions should also.
I'm not sure if there's a performance reason to have the conditional all on one line, but this was a little easier for me to Grok:
if (isset($result->expire) && $result->expire !== CACHE_PERMANENT && $result->expire <= time()) {
if (class_exists('Memcached') && $mc->add($full_key .'_semaphore', '', variable_get('memcache_stampede_semaphore', 15))) {
$result = FALSE;
}
elseif ($mc->add($full_key .'_semaphore', '', FALSE, variable_get('memcache_stampede_semaphore', 15))) {
$result = FALSE;
}
}
Comments
Comment #1
a5342346 commentedwith,
pressflow6, revno: 82
drush pm-list | grep -i mem
Caching Memcache Admin (memcache_admin) Module Not installed 6.x-1.x-dev
and,
memcached-1.4.5
libmemcached, revno: 839
php-memcached, commit 113328139bdb7bb4adb4f63040289f3dd73c988d, Fri May 7 09:27:34 2010 -0700
i'm seeing a similar message.
e.g., @ .../admin/settings/performance, i get a couple dozen of these,
warning: Memcached::set() expects at most 3 parameters, 4 given in /srv/www/test/sites/all/modules/memcache/dmemcache.inc on line 42.
my settings.php stanza is,
_is_ there a workaround? just not clear to me from the OP.
thanks
ben
Comment #2
jeremy commentedThanks, Josh. This was fixed earlier in the D7 branch, but somehow didn't make it into the D6 branch. The fix was to call dmemcache_set, rather than calling ->set directly. This is a little more funky in D6, but prevents having to duplicate logic.
Fix committed here:
http://drupal.org/cvs?commit=366748
Please test.
Comment #3
jeremy commentedBTW: In response to your other comment, Josh, the dmemcache_get calls currently only set the first parameter to ->get, so currently there's nothing to work around there when switching between memcache and memcached. As far as I know, this last bug fix should be all we need to properly auto-switch between the memcache and memcached PECL extensions.
Comment #4
a5342346 commented> please test
dl'ing from CVS (2010-05-15) ...
drush pm-list | grep -i memcache
Memcached::set() expects at most 3 parameters, 4 given in /svr/www/sites/all/modules/memcache/dmemcache.inc on line 42.[warning]
Memcached::set() expects at most 3 parameters, 4 given in /svr/www/all/modules/memcache/dmemcache.inc on line 42.[warning]
Caching Memcache Admin (memcache_admin) Module Enabled
WD php: Memcached::set() expects at most 3 parameters, 4 given in /svr/sites/all/modules/memcache/dmemcache.inc on [error]
where, in settings.php,
Comment #5
divbox commentedsame error. using code from cvs. 05/20/10
* warning: Memcached::set() expects at most 3 parameters, 4 given in /var/www/sites/all/modules/memcache/dmemcache.inc on line 42.
* warning: Memcached::set() expects at most 3 parameters, 4 given in /var/www/sites/all/modules/memcache/dmemcache.inc on line 42.
settings.php
drush pm-list | grep -i memcache
Caching Memcache Admin (memcache_admin) Module Enabled 6.x-1.x-dev
Comment #6
divbox commentedI fixed this by adding the code from the CVS fix committed here http://drupal.org/cvs?commit=366748 to line 42 in dmemcache.inc and all is well. I should have tried this the other day!
Comment #7
jeremy commentedGreat news -- looks like we're good for a 1.5 stable release then.
Comment #9
a5342346 commentedi just DL'd today's,
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -d memcache-DRUPAL-6--1 -r DRUPAL-6--1 contributions/modules/memcache/
which i presume should have the commit from May 13, 2010 (http://drupal.org/cvs?commit=366748) integrated, right?
still seeing scads of these errors:
* warning: Memcached::set() expects at most 3 parameters, 4 given in /var/www/sites/all/modules/memcache/dmemcache.inc on line 42.
* warning: Memcached::set() expects at most 3 parameters, 4 given in /var/www/sites/all/modules/memcache/dmemcache.inc on line 42.
do we need to manually apply the source change(s)?
Comment #10
a5342346 commentedoh, should mention:
grep Id dmemcache.inc
// $Id: dmemcache.inc,v 1.1.2.7.2.12 2010/05/26 21:37:11 Jeremy Exp $
Comment #11
a5342346 commentedfound the/my problem ...
i'd built/installed latest pecl php-memcached extension, and enabled it in .ini config, but did NOT *dis*able the memcache (no -d) extension.
simply ensuring that the 'old' "non-d" extension is OFF, i.e.,
cd /etc/php5/conf.d
grep memcach * | grep extension
memcached.ini:extension = memcached.so
memcache.ini:;extension = memcache.so
seems, so far, to cure the problem. site's up, and I'm seeing memcache hits as expected.
Comment #12
Ankit22 commentedMy settings.php looks like this
$conf['cache_inc'] = './sites/all/modules/cacherouter/cacherouter.inc';
$conf['cacherouter'] = array(
'default' => array(
'engine' => 'memcache',
'server'=> array
('localhost:11211'),
'shared'=>TRUE,
'prefix'=>'',
),
'cache_form' => array(
'engine' => 'file',
'servers' => array(),
'shared' => TRUE,
'prefix' => '',
'path' =>
'sites/default/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
);
Can you tell me weather it is correct to do it this way?