Dear All,
I`m really new to memcache and I thought of trying it out in my windows machine before move out to linux server. I successfully enabled the memcached extension and also in my phpinfo() it shows it successfully installed.

Then I tried the simple code which was present in the php.net to test my memcache capability but unfortunately the script died giving following error,

Warning: Memcache::connect() [memcache.connect]: Can't connect to localhost:11211, A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060) in 

below is the PHP code ,


$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");

$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";

$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;

$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";

$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";

var_dump($get_result);

what i`m doing wrong?

Thanks,
best Regards,
niroshan

    Hi Guys!

    The reason it says couldn't connect because i was n`t running the daemon. When you install the memcached it only install the extension and this gives the interface (functions) to access the memcache but to be able to store and retrieve data you need to install and run the daemon.

    Please remember I only tried this in windows machine yet and since it is a success i now will be moving out to linux. So anyone whos want to run memcahed in windows and try here a link to download the memcached daemon.

    http://jehiah.cz/projects/memcached-win32/

    Thanks,
    Best Regards,
    Niroshan

      Write a Reply...