I have memcache installed on my RHEL machine. The following script works perfectly when I execute the php script at the command prompt. However, when I try to execute this script from a browser, it returns 'Could not connect'.
I have:
- changed localhost to 127.0.0.1
- checked the port 11211 and it is open
- ps -eaf | grep memcached returns
00:00:00 memcached -d -p 11211 -u memcached -m 255 -c 1024 -/var/run/memcached/memcached.pid
which means any IP is allowed on port 11211.
What am I missing?
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ('Could not connect');
$version = $memcache->getVersion();
echo 'Server’s version: '.$version;
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$numb = array("numb" => 45, "Love" => "Life");
$memcache->set('GOLD', 44, false, 5000) or die ('Failed to save data at the server');
$_SESSION['client_id'] = 45;
echo 'Store data in the cache (data will expire in 10 seconds)';
I have:
- changed localhost to 127.0.0.1
- checked the port 11211 and it is open
- ps -eaf | grep memcached returns
00:00:00 memcached -d -p 11211 -u memcached -m 255 -c 1024 -/var/run/memcached/memcached.pid
which means any IP is allowed on port 11211.
What am I missing?
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ('Could not connect');
$version = $memcache->getVersion();
echo 'Server’s version: '.$version;
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$numb = array("numb" => 45, "Love" => "Life");
$memcache->set('GOLD', 44, false, 5000) or die ('Failed to save data at the server');
$_SESSION['client_id'] = 45;
echo 'Store data in the cache (data will expire in 10 seconds)';