<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1555" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi Guys,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Just starting with memcached and php4 , and i just
cant get this to work , all i want is to store the mysql result into memcache
for future use , but somehow it doesn't work and i can't find any solution
googling around...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Maybe someone from this list could help me out
?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>It always rreturns as 'not cached' thus hitting the
DB .</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The code :</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2><?php<BR>include_once('../inc/db.inc');</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>$memcache = new
Memcache;<BR>$memcache->connect('IP', 1211) or die ("Could not
connect");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>$version = $memcache->getVersion();<BR>echo
"Server's version: ".$version."<br/>\n";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>$test = $memcache->get('testqry');</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>if (!$test) {<BR> <BR> $time =
microtime();<BR> $time = explode(" ", $time);<BR> $time = $time[1] +
$time[0];<BR> $start = $time;<BR> <BR> echo "testqry is not
cached.<br><Br>";<BR> <BR> $qry = "SELECT *
from large_db ORDER by ID";<BR> $res = mysql_query($qry) or
die(mysql_error());<BR> <BR> while ($row = mysql_fetch_array($res))
{<BR> <BR> echo $row['id']." - ".$row['title']." -
".$row['url']."<br>";<BR> <BR> }<BR> <BR> <BR> $memcache->set('testqry',
$res, true, 600)or die("set failed");<BR> <BR> echo "Result stored in
cache";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>} else { </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><BR> <BR> echo "testqry was
cached.<br><Br>";<BR> <BR> $res =
$memcache->get('testqry');<BR> <BR> echo
$res;<BR> <BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>?></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Thanks in advance,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
Martin</FONT></DIV></BODY></HTML>