• Resolved Brooke.

    (@brookedot)


    My Memcached instance is protected with SASL and requires a username and password to access. I connect to my Memcached server outside of WordPress I pass a few extra options to the class to authentication the connection. Typically that connection would look something like this:

    $memcache = new Memcached();
    $memcache->setOption( Memcached::OPT_BINARY_PROTOCOL, true );
    $memcache->setSaslAuthData( "memcached_user", "hunter2" );
    $memcache->addServer( '127.0.0.1', 11211 ) or die ("Could not connect");

    When I started looking to use Memcache for WordPress there was very little discussion around SASL usage with existing drop-in options. It would be great to see these options added to this plugin allowing the connection to be made.

    When I attempted to install the plugin as is I get a 504 timeout in the browser due to the server connection failing authentication to Memcached().

    I reviewed the plugin’s code and didn’t see a way to add SASL but I think since this is “advanced” having it defined as a constant would be the easiest way.

    • This topic was modified 2 years, 4 months ago by Brooke..
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Brooke.

    (@brookedot)

    Turns out since I use Memcached at PHP and not memcache the Memcached Redux plugin was actually the right solution for me.

    However, since this codebases are largely the same I thought I’d share my solution in the event that he helps others. I added the following to line 464 prior to $this->mc[$bucket]->addServers

    $this->mc[$bucket]->setOption(\Memcached::OPT_BINARY_PROTOCOL, true );
    $this->mc[$bucket]->setSaslAuthData('user', 'hunter2' );
    $this->mc[$bucket]->addServers( $instances );

    This could be marked as “resolved” as this technically solves the problem but I’d love to see this built in as an option, likely just by setting a constant. Is there a public repo where a PR could be sent?

    Plugin Contributor Andrija Vu?ini?

    (@aidvu)

    You could try here: https://github.com/Automattic/wp-memcached. Thanks for the report.

    We try to have those two repos in sync, and release as time permits.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add support for Memcached SASL’ is closed to new replies.