views:

270

answers:

2

I have XAMPP 1.7.3 installed on Windows 7. The PHP version is 5.3.1. I have successfully installed memcache for win32 from http://www.splinedancer.com/memcached-win32.

I got PHP extension php_memcache.dll from http://downloads.php.net/pierre.

Restarting apache and checking phpinfo() shows memcache is OK.

When I test it with below PHP page. It always fail in set method.

<?php
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect");

$version = $memcache->getVersion();
echo "Server's version: ".$version." \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)\n";

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

The set method always return false so it constantly output

Server's version: Failed to save data at the server

I'm stuck. I don't know which way to trouble shoot this issue. Anybody has any idea about possible direction?

Thanks.

A: 

OK, first realise that I've never used Memcache on Windows. However, surely the phpinfo() stuff is just telling you that the extension is OK, not memcache itself... with that in mind, are you sure it's not being firewalled or something? Check that the Windows firewall is disabled would be my first 'guess'...

Narcissus
A: 

do you get any php errors or warnings ?
you could try var_dump($memcache->getStats())
also try writing just some string into memcache instead of that object
and check if you can connect to that memcache with telnet 127.0.0.1 11211
if nothing helps try using a different server for memcache... doesn't windows firewall block that port ?

jab11
The port is not blocked by firewall, since I can "telent 127.0.0.1 11211" successfully.I tried to type "stats<CR>" in telnet connection. The connection is aborted immediately. Also, I tried to type "set mykey 0 0 4<CR>what<CR>" in telnet. Same result. It looks that the memcached just fail in silence.
Morgan Cheng