XF 1.2 Memcached problem

TPerry

Well-known member
I have just installed memcached on my dedicated server (Debian Wheezy) and enabled (per the manual) the backend.
When I go to the site I now get
Code:
An exception occurred: The memcache extension must be loaded for using this backend ! in /var/www/twowheel/library/Zend/Cache.php on line 209

Zend_Cache::throwException() in Zend/Cache/Backend/Memcached.php at line 123
Zend_Cache_Backend_Memcached->__construct() in Zend/Cache.php at line 153
Zend_Cache::_makeBackend() in Zend/Cache.php at line 94
Zend_Cache::factory() in XenForo/Application.php at line 718
XenForo_Application->loadCache()
call_user_func_array() in XenForo/Application.php at line 921
XenForo_Application->lazyLoad() in XenForo/Application.php at line 952
XenForo_Application::get() in XenForo/Application.php at line 1376
XenForo_Application::getCache() in XenForo/Model.php at line 146
XenForo_Model->_getCache() in XenForo/Model/DataRegistry.php at line 81
XenForo_Model_DataRegistry->getMulti() in XenForo/Dependencies/Abstract.php at line 144
XenForo_Dependencies_Abstract->preLoadData() in XenForo/FrontController.php at line 127
XenForo_FrontController->run() in /var/www/twowheel/index.php at line 13

The PHP5 module looks to be loaded
screenshot.webp
screenshot1.webp
I've given it 512MB for the cache in memcached.conf.

When checking netstat I get this
Code:
netstat -tap | grep memcached
tcp        0      0 localhost:11211         *:*                     LISTEN      3542/memcached

I've restarted php5-fpm numerous times as well as nginx.

I've tested to see that it is loaded using a test php file containing
Code:
<?php
$mc = new Memcached();
$mc->addServer("127.0.0.1", 11211);
.
$result = $mc->get("test_key");
.
if($result) {
  echo $result;
} else {
  echo "No data on Cache. Please refresh page pressing F5";
  $mc->set("test_key", "test data pulled from Cache!") or die ("Failed to save data at Memcached server");
}
?>
and I get the test data pulled from Cache! statement when browsing to it and refreshing - which I believe indicates that the cache is working.

Any hints on where to look?

This was resolved by further testing by me. In addition to doing having to do
Code:
aptitude install memcached php5-memcached
you have to also do
Code:
aptitude install php5-memcache
 
Last edited:
EDIT:

I had this same issue! There are two PHP memcache extensions - memcache, and memcached. You need the memcache extension installing :)

Liam
 
You do.

Code:
$config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
So this would work (I was using APC but it started giving me some headaches with registrations failing and installed Xcache).
Code:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'jsa_';

$config['cache']['cacheSessions'] = true;

#$config['cache']['backend'] = 'xcache';

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

        // memcached port
            'port' => 11211,
    )
    )
);
 
This is what I use:

Code:
$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array('caching'  =>  true,
                                            'automatic_serialization' => true,
                                            'lifetime'    => 1800,
                                            'cache_id_prefix'  =>  'orchids_'
);
$config['cache']['cacheSessions'] = true;
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
            'servers' =>array(
                            array(
                                'host' => '127.0.0.1', // your memcached server ip /address
                                'port' => 11211        // memcached port
                            )
                        ),
            'compression' => false
);
 
I've never had the lifetime value set in my cache config.
I'll probably take it out.. I'm mainly just playing with memcache right now, in conjunction with xCache.
If found if I left the
Code:
'automatic_serialization' => true,
statement in from @BamaStangGuy example the site would error out.
I think it's because I don't have igbinary support compiled in - just json?
 
Well, got memcache/memcached configured on both servers and set up the config.php to use both for fall-over. Hardest part was getting iptables configured... but once I did that she's working like a champ.
Now I just have to figure out how to get the myBB forums to use either server. Just gotta spend some time over at that other site researching - and it may not be able to do it in the config.php (assign an array).
 
Well, got memcache/memcached configured on both servers and set up the config.php to use both for fall-over. Hardest part was getting iptables configured... but once I did that she's working like a champ.
Now I just have to figure out how to get the myBB forums to use either server. Just gotta spend some time over at that other site researching - and it may not be able to do it in the config.php (assign an array).

Should be possible in MyBB. Ask in the BBO forum if you've got access.
 
Should be possible in MyBB. Ask in the BBO forum if you've got access.
Kicked over to the myBB support forum and inquired. I found a blurb about it being supported on their "latest and greatest additions to 1.6" page - but absolutely no information on how to implement it. :whistle:
We'll see how great the support there is compared to over here. Of course, I'm spoiled now as usually over here you get an answer fairly quickly. :D
 
Kicked over to the myBB support forum and inquired. I found a blurb about it being supported on their "latest and greatest additions to 1.6" page - but absolutely no information on how to implement it. :whistle:
We'll see how great the support there is compared to over here. Of course, I'm spoiled now as usually over here you get an answer fairly quickly. :D

It'll be an interesting experiment. back in the heyday when I joined the team, you would have had an answer from matt within an hour.
 
I have a same problem.

Trying to install memcached in Wheezy. I have installed php5-memcache, php5-memcached and memcached.

And when I test it with this:

Code:
<?php
$mc = new Memcached();
$mc->addServer("127.0.0.1", 11211);
.
$result = $mc->get("test_key");
.
if($result) {
echo $result;
} else {
echo "No data on Cache. Please refresh page pressing F5";
$mc->set("test_key", "test data pulled from Cache!") or die ("Failed to save data at Memcached server");
}
?>

Nothing appear. Just a white blank screen.

Any suggestion?
 
Okay so I try to use this code to test:
Code:
$m =newMemcached();
$m->addServer('localhost',11211);
$m->set('key','hello world');
var_dump($m->get('key'));

And the result is good. Memcached got it. But just that file only.

Why memcached doesnt work with my forum?
 
Top Bottom