Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, guys. I am using PECL memcached and my memcache server is a remote server. I can configure PHP for a PECL memcached without SASL. But I don't know how to use this with SASL. Can someone give me a tip? I check the internet, but the articles are out of date. Many thanks!
Comments
Comment #1
Jeremy CreditAttribution: Jeremy commentedI don't recommend running Memcached on a remote network. Memcached is typically used as a caching layer with Drupal, and this needs to be fast. Putting memcached on a remote network will introduce network latency, and could result in your caching layer slowing things down rather than speeding them up.
Further, it looks like 1) you'll have to use the PECL memcached (note the 'd' at the end) extension which is not recommended, 2) you'll have to enable the Binary protocol on the client, 3) you'll have to launch the memcached binary with the -S flag (see https://code.google.com/p/memcached/wiki/SASLHowto ), and 4) the memcache Drupal module likely will have to be patched to properly authenticate with each connection (see http://php.net/manual/en/memcached.setsaslauthdata.php ).
Leaving this as a feature request, as #4 will require a patch. I have no intention of working on this myself, but patches are welcome.
Comment #2
elantion CreditAttribution: elantion commentedYes, I have to do those requests as you said. And now, I can make it work now.
At the function "dmemcache_connect" in dmemcache.inc, I just add some settings in this function and it work.
Like this:
$rc = $memcache->setOption(Memcached::OPT_COMPRESSION, false);
$rc = $memcache->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$rc = $memcache->addServer('remote.server.com', 11211);
$rc = $memcache->setSaslAuthData('username', 'password');
I don't kown why this can work , I just did.
Comment #3
Jeremy CreditAttribution: Jeremy commentedThe first three options you can actually set in settings.php. You'd do something like this (better explained in README.txt):
It's only the final option (->setSaslAuthData) that requires a patch.
I'm glad to hear it's working for you. Leaving open as a feature request so that this can be fully configured from settings.php and without patching dmemcache.inc.
Comment #5
Jeremy CreditAttribution: Jeremy commentedI've added SASL support, documented in the README:
http://cgit.drupalcode.org/memcache/commit/?id=773d3e8
Tagging to be ported to 6.x-1.x.
Comment #6
Jeremy CreditAttribution: Jeremy at Tag1 Consulting commentedBack ported:
http://cgit.drupalcode.org/memcache/commit/?id=997f1f1