Multiple Memcache Servers Config File Setting

Brent W

Well-known member
How should I configure my config.php file to point to more than one memcached server?

Currently have one setup but want to create another so that the forums can fall back to it in case one fails.
 
I believe it would be as follows.

Code:
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            // your memcached server IP /address
            'host' => 'localhost',
           
            // memcached port
            'port' => 11211,
        )
    )
    'servers' => array(
        array(
            // your memcached server IP /address
            'host' => 'localhost',
           
            // memcached port
            'port' => 11211,
        )
    )
);

If that doesn't work

Code:
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            // your memcached server IP /address
            'host' => 'localhost',
           
            // memcached port
            'port' => 11211,
        )
       array(
            // your memcached server IP /address
            'host' => 'localhost',
           
            // memcached port
            'port' => 11211,
        )
    )
);
 
Thanks I will give those a try. Should I miss with the weight option between the servers?

I don't thinkso, this way the data *should* be identically copied and served to and from each server, and should one fail the other will carry on without issue...

thats the theory at least...
 
I believe it would be as follows.

Code:
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            // your memcached server IP /address
            'host' => 'localhost',
       
            // memcached port
            'port' => 11211,
        )
    )
    'servers' => array(
        array(
            // your memcached server IP /address
            'host' => 'localhost',
       
            // memcached port
            'port' => 11211,
        )
    )
);

If that doesn't work

Code:
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            // your memcached server IP /address
            'host' => 'localhost',
       
            // memcached port
            'port' => 11211,
        )
      array(
            // your memcached server IP /address
            'host' => 'localhost',
       
            // memcached port
            'port' => 11211,
        )
    )
);

I've tried both of these to get my primary server to use the second install of memcache on my second server, and neither work

I get this error
Code:
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /home/z22se/public_html/forum/library/config.php on line 31

Example:
Code:
$config['cache']['backendOptions']=array(
        'compression'=>false,
        'servers' => array(
                array(
                        'host'=>'localhost',
                        'port'=>11211,
                )     
                array(        #This is line 31
                        'host'=>'IP ADDRESS',
                        'port'=>11211,
                )
               
        )
);


Code:
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /home/z22se/public_html/forum/library/config.php on line 32

Code:
$config['cache']['backendOptions']=array(
        'compression'=>false,
        'servers' => array(
                array(
                        'host'=>'localhost',
                        'port'=>11211,
                )     
        )     
        'servers' => array( # This is line 32
                array(
                'host'=>'IP ADDRESS',
                'port'=>11211,
                )
        )
);
 
Think I've fixed it.

It was missing a comma between the two arrays

Code:
$config['cache']['backendOptions']=array(
        'compression'=>false,
        'servers' => array(
                array(
                        'host'=>'localhost',
                        'port'=>'11211'
                ),
                array(
                        'host'=>'IP ADDRESS',
                        'port'=>'11211'
                )
        )
);
 
Hi all, anyone able to clarify, how this config should look like in Xenforo 2.

Documentation explains just 1 memcached server:

PHP:
$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'Memcached';
$config['cache']['config'] = [
    'server' => '127.0.0.1'
];

Thanks a lot
 
Hmm...Looking into the CacheFactory.php I think something like this should do:

PHP:
$config['cache']['config']['servers'] = array(
    array( 'IP1', 11211),
    array( 'IP2', 11211)
);

So pretty much same think as for Xen 1
 
Top Bottom