[eluser]RMinor[/eluser]
I recently installed Memcached onto my MAMP 2.2 local setup (running OSX Mavericks). The installation appears to be successful (see attached screenshot). I have a base controller that checks if Memcached is supported and stores that in a variable in case I ever move to an environment where Memcached is not supported. When I use that variable to test, it says that Memcache is supported. However, when I try to save or get data from Memcached it doesn't work. Here is some of my code.
Controller testing of Memcached:
Code:
if ($this->_memcached_supported) { // $this->_memcached_supported comes from MY_Controller
echo 'Memcached supported!';
}
$data = $this->cache->memcached->get('foo');
if (!$data) {
echo 'No cache data stored!<br />';
$data = 'bar';
$this->cache->memcached->save('foo', $data, 60);
}
echo $data;
echo '<pre>';
var_dump($this->cache->memcached->cache_info());
echo '</pre>';
The above code outputs:
"Memcached supported!No cache data stored!
bar"
which is correct except when I navigate back to that page it should change, but it doesn't. Below is the output from var_dump() of cache_info():
Code:
array (size=1)
'localhost:11211' =>
array (size=24)
'pid' => int -1
'uptime' => int 0
'threads' => int 0
'time' => int 0
'pointer_size' => int 0
'rusage_user_seconds' => int 0
'rusage_user_microseconds' => int 0
'rusage_system_seconds' => int 0
'rusage_system_microseconds' => int 0
'curr_items' => int 0
'total_items' => int 0
'limit_maxbytes' => int 0
'curr_connections' => int 0
'total_connections' => int 0
'connection_structures' => int 0
'bytes' => int 0
'cmd_get' => int 0
'cmd_set' => int 0
'get_hits' => int 0
'get_misses' => int 0
'evictions' => int 0
'bytes_read' => int 0
'bytes_written' => int 0
'version' => string '' (length=0)
Below is my memcached.php config file:
Code:
$config = array(
'default' => array(
'host' => 'localhost',
'port' => 11211,
'weight' => 1
)
);
Has anybody used Memcached with CI successfully and can help me out? Thank you in advance.