1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 Memcached problem

Discussion in 'Troubleshooting and Problems' started by Tracy Perry, Oct 3, 2013.

  1. Tracy Perry

    Tracy Perry 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.png
    screenshot1.png
    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: Oct 3, 2013
  2. Liam W

    Liam W Well-Known Member

    EDIT:

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

    Liam
     
  3. Tracy Perry

    Tracy Perry Well-Known Member

    Yep... just updated the post with the solution I figured out. ;)
     
  4. Liam W

    Liam W Well-Known Member

    Yeah, it threw me the first time I tried. Stupid extension names...

    Glad it's sorted for you now though :)

    Liam
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That refers to the PHP configuration. Check admin.php?tools/phpinfo . Make sure memcache shows in there.
     
  6. Liam W

    Liam W Well-Known Member

    Did you read the replies before you posted your reply?

    Just wondering :)
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    No.
     
    Steve F likes this.
  8. Tracy Perry

    Tracy Perry Well-Known Member

    Now I got to research if you are using multiple forums on one server using memcache if you need to set a specific key for each one.
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You do.

    Code:
    $config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
    
     
    Steve F likes this.
  10. Tracy Perry

    Tracy Perry Well-Known Member

    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,
        )
        )
    );
    
     
  11. BamaStangGuy

    BamaStangGuy Well-Known Member

    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
    );
     
    TheComputerGuy likes this.
  12. Tracy Perry

    Tracy Perry Well-Known Member

    Thanks... would not
    Code:
    'lifetime'    => 1800,
    cause the cache to dump after 30 minutes if you are caching sessions?
     
  13. MattW

    MattW Well-Known Member

    I've never had the lifetime value set in my cache config.
     
  14. Tracy Perry

    Tracy Perry Well-Known Member

    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?
     
  15. Tracy Perry

    Tracy Perry Well-Known Member

    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).
     
    euantor likes this.
  16. euantor

    euantor Well-Known Member

    Should be possible in MyBB. Ask in the BBO forum if you've got access.
     
  17. Tracy Perry

    Tracy Perry Well-Known Member

    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
     
  18. euantor

    euantor Well-Known Member

    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.
     
  19. Sheratan

    Sheratan Well-Known Member

    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?
     
  20. Sheratan

    Sheratan Well-Known Member

    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?
     

Share This Page