• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Codeigniter2. Problems with Memcached

#1
[eluser]zebric[/eluser]
Hi all! Somehow, this does not work code:
Code:
$this->load->driver('cache');
$this->cache->memcached->save('var_name', 'var_value', 60);
echo $this->cache->memcached->get('var_name');

As a result of an error:
Fatal error: Call to a member function add () on a non-object in: system \ libraries \ Cache \ drivers \ Cache_memcached.php on line 67

In line 67 the method save:
Code:
public function save ($ id, $ data, $ ttl = 60)
{
return $ this-> _memcached-> add ($ id, array ($ data, time (), $ ttl), $ ttl);
}

Add method somehow I do not see ...., maybe this problem?

#2
[eluser]InsiteFX[/eluser]
_memcached is the memcache object!

Check your apache httpd.conf file and make sure that it is loading the memcache module.
Code:
// remove the # sign if it is there to load the memcache module.
// the .so is for Windows it will be .so or .c
#LoadModule mem_cache_module modules/mod_mem_cache.so

InsiteFX

#3
[eluser]zebric[/eluser]
This issue I decided as follows: in file Cache_memcached.php added constructor
Code:
function __construct() {
    if(!$this->_memcached)
    {
    $this->_memcached = new Memcache();
    $this->_memcached->connect('localhost', 11211);
    
    }
}

#4
[eluser]bunal[/eluser]
The problem in the CI library is that it is looking for the apache module mod_memcached not the php extension in which most cases it is used.

Cache_memcached.php

Line 192

Code:
if ( ! extension_loaded('memcached'))

Which should be below, if loaded as extension

Code:
if(class_exists('Memcache')){

Line 156

Code:
$this->_memcached = new Memcached();

Which should be below, if loaded as extension

Code:
$this->_memcached = new Memcache();

#5
[eluser]zebric[/eluser]
As they say Ukrainian "Thank you very much!"

#6
[eluser]bunal[/eluser]
As they say Turkish "Your welcome" Wink


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.