XF 2.0 Using libmemcached backend cache ?

eva2000

Well-known member
I am still on XF 1.5 and haven't touched XF 2 since the betas right now but need clarification as to whether XF 2 supports using Libmemcached backend cache for memcached pecl php usage as opposed to Memcached backend using memcache pecl php extension usage ? PHP 7.3 seems to lack memcache pecl php extension support so using Libmemcached backend cache with memcached pecl php extension seems like the only way forward with PHP 7.3 AFAIK ?

With XF 1.5 I had
Code:
$config['cache']['enabled'] = true;
$config['cache']['cacheSessions'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array(
'caching' => true,
'cache_id_prefix' => 'xfxx_',
'automatic_serialization' => false,
'lifetime' => 0
);

$config['cache']['backend'] = 'Libmemcached';

$config['cache']['backendOptions'] = array(
'servers' => array(
array(
'host' => '127.0.0.1',
'port' => 11211,
'weight' => 1
)
)
);
What would be the equivalent for XF 2 if Libmemcached backend is supported ?

Also which version of Zend Framework is XF 1.5 and XF 2.0 based on ? For looking up documentation wise https://framework.zend.com/manual/1.11/en/zend.cache.backends.html#zend.cache.backends.libmemcached ?
 
Last edited:

Jeremy P

XenForo developer
Staff member
I'm not sure what all is officially supported, but XF1 uses ZF (1.11) for caching and XF2 uses Doctrine (1.5). Both libraries support Memcache and Libmemcached backends, and I have used Libmemcached on XF1 without issue. Given they're just back-end drivers and implement a common interface, I wouldn't expect there to be problems using any of the available providers on either version (but I don't know that for sure).
 

eva2000

Well-known member
Ah so XF2 using Doctrine really means using Provider = Memcached means Memcached pecl PHP extension according to https://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/caching.html unlike ZF where backend Memcached = memcache pecl php extension and Libmemcached meant memcached pecl php extension.

so with XF2 to use memcached pecl php extension with memcached server would be something like following if you need to define the memcached port
PHP:
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['namespace'] = 'your_prefix';
$config['cache']['config'] = [
    'servers' => [
        ['memcached.hostname.com', 11211, 100] // host, port, weight
    ]
];
$config['cache']['provider'] = 'Memcached';
 

Ludachris

Well-known member
Hey George, after upgrading to PHP 7.2 recently and updating to XF 1.5.23 I had some issues with Memcache/Memcached. My host says the site is configured to use "memcache" not "memcached" even though I have this in my config file:

PHP:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            // your memcached server IP /address
            'host' => 'localhost',
            
            // memcached port
            'port' => 11211,
        )
    )
);
They also say we should consider using Memcached because Memcache support is going away. I don't see how the site could be configured wrong based on what you said above.
 

Kirby

Well-known member
On XF 1.5 cache backend memcached is effectively memcache, if you want to use memcached you must configure the backend as Libmemcached.

$config['cache']['backend'] = 'Libmemcached';

Yes, this is confusing :)
 

Ludachris

Well-known member
On XF 1.5 cache backend memcached is effectively memcache, if you want to use memcached you must configure the backend as Libmemcached.

Yes, this is confusing :)
Wow, okay, will do that. So in my config settings above, all I have to do is change the backend setting, correct? The other settings stay the same?
 
Top