How to troubleshoot memcache set method always fail issue?

Posted by Morgan Cheng on Stack Overflow See other posts from Stack Overflow or by Morgan Cheng
Published on 2010-03-26T10:27:27Z Indexed on 2010/03/26 10:33 UTC
Read the original article Hit count: 295

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about xampp