memcached不工作xampp窗口

时间:2013-03-18 05:41:07

标签: php memcached

include 'php/db.php';
$qry = "select * from dsb_online";
$result = mysql_query($qry,$link);

if (!$result) {
    die('Invalid query: ' . mysql_error());
}
while ($row = mysql_fetch_assoc($result)) {

   $s=array($row['fk_user_id'],$row['last_activity']);
}

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

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

$memcache->set('key', $s, 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);  

我在我的xampp中安装了memcached。这是我正在运行的测试文件来测试它。 我得到的输出是

Server's version: 1.2.6
Store data in the cache (data will expire in 10 seconds) 
Data from the cache:
array(2) { [0]=> string(1) "3" [1]=> string(19) "2013-02-11 11:54:44" }

现在我修改了这样的代码来测试是否从memcached中检索数据

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

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


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

var_dump($get_result);  

结果是

Server's version: 1.2.6
Data from the cache:
bool(false)

任何人都可以告诉我为什么我的缓存无法正常工作

0 个答案:

没有答案