Why does my site go "unexpected error" when I enable caching?

Coop1979

Well-known member
This has been plaguing me and I feel like there's a simple solution. I recently upgraded to PHP 7 and since then my cache setttings won't work. At first I thought it was because opcache and memcached weren't properly compiled into my install of PHP7, but I have subsequently rebuilt it and in my phpinfo page it shows Memcached and Opcache compiled correctly.

But, I'm still having troubles with the site throwing the "An unexpected error occurred. Please try again later." error.

This is my config section with the caching details:

PHP:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'pc_';
$config['cache']['cacheSessions'] = true;

$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            // your memcached server IP /address
            'host' => 'localhost',
          
            // memcached port
            'port' => 11211,
        )
    )
);
 
OK, I've narrowed it down to a Memcached issue. Normal caching works, but if I enable Memcached it throws the error. After doing some reading, it appears that XenForo requires "Memcache", which is not available on PHP 7.

Is that correct?
 
I think both Memcache/Memcached/Libmemcached are all supported by XenForo.
Maybe I'm wrong.
 
OK, I've narrowed it down to a Memcached issue. Normal caching works, but if I enable Memcached it throws the error. After doing some reading, it appears that XenForo requires "Memcache", which is not available on PHP 7.

Is that correct?
I believe so, the "memcache" extension wasn't working with PHP 7 last I checked. I have had success in using Libmemcached (memcached) as a caching back-end with PHP 7. It's not documented in the XenForo manual, but it is bundled with XenForo in the Zend Framework and appears to work fine out of the box.

http://framework.zend.com/manual/1.12/en/zend.cache.backends.html#zend.cache.backends.libmemcached
 
Top Bottom