WordPress.org

Ready to get started?Download WordPress

Forums

Memcached Object Cache
Memcached with Unix socket (6 posts)

  1. guiribeiro
    Member
    Posted 11 months ago #

    Hi there,

    I'm using Memcached with Unix socket on a single site VPS. I would like to know if I can make this plugin work with Unix socket instead of TCP... any ideas?

    Thanks

    http://wordpress.org/extend/plugins/memcached/

  2. laowang1
    Member
    Posted 10 months ago #

    I would also like to know.

  3. laowang1
    Member
    Posted 10 months ago #

    I add line in wp-config.php
    $memcached_servers = array(
    'default' => array(
    'unix:/xxxx/xxx/memcached.socket'
    )
    );

    then get error log:
    "NOTICE: PHP message: PHP Warning: MemcachePool::add(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /wp-content/object-cache.php on line 121"

  4. novazembla
    Member
    Posted 8 months ago #

    Just stumbled over this post. It's a bit late but for future reference ...

    $memcached_servers = array(
      'default' => array(
        'unix:///tmp/memcached.socket'
      )
    );

    Works for me. Think the tripple slash is the secret sauce :-)

  5. wp-buddy
    Member
    Posted 6 months ago #

    Hey guys,
    the PHP documentation says that if when sockets are used you have to set the port to 0.

    So something like this in wp-config.php could help:

    $memcached_servers = array(
      'default' => array(
        'unix:///tmp/memcached.socket:0
      )
    );

    But I didn't get it to work either :(

  6. philipnet
    Member
    Posted 5 months ago #

    The code at line 374:
    list ( $node, $port ) = explode(':', $server);
    splits the string 'unix:///tmp/memcached.socket:0' into 'unix' and '///tmp/memcached.socket:0'

    It then compares '///tmp/memcached.socket:0' to a numerical port number (which is not true) and so sets the port to '11211' and then tries to connect to 'unix:11211', which fails.
    :(

    The revised code here:
    list ( $host, $node, $port ) = explode(':', $server);
    if ( $host == "unix" )
    { $node = "unix:" . $node; }
    else
    { $port = $node;
    $node = $host; }

    fixes it for socket connections to Memcache.

    TCP connections to Memcache should remain unaffected - but I haven't tested that.

Reply

You must log in to post.

About this Plugin

About this Topic