Pear DB and memcached

From: Date: Tue, 06 Jun 2006 13:55:03 +0000
Subject: Pear DB and memcached
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-237457@lists.php.net to get a copy of this message
Hi, Im having a trouble using memcached with pear db. When im using memcache to store and retrieve an string, all works fine. When Im using memcache to store a pear db resulset, it does not work!! This retrieves data but pear::db does not understand it. I really dont know Any ideas? Thanks in advance Code: $sql = "SELECT * FROM anytable"; $myownqry= cachedSQL($sql); while ($rs_qryPhoto =& $myownqry->fetchRow()) {
   echo "OK<bR>";    //When variable is taken from cache, nothink is shown!!!
} $MEMCACHE_CONNECTED=0; $MEMCACHE_STR=""; function memcachedConnect(){ global $MEMCACHE_CONNECTED,$MEMCACHE_STR; if(!($MEMCACHE_CONNECTED)){
       $MEMCACHE_CONNECTED=1;
       $MEMCACHE_STR = memcache_connect('192.168.2.8', 11211);
} } function cachedSQL($sSQL) { global $db,$MEMCACHE_CONNECTED,$MEMCACHE_STR; memcachedConnect(); if($tmp=memcache_get($MEMCACHE_STR,MD5($sSQL))){
           echo "Cached<br>";
           //echo var_dump($tmp);
}else{
       $tmp = $db->query($sSQL);
       //echo var_dump($tmp);
       echo "<b>NOT</b> Cached<br>";
       memcache_set($MEMCACHE_STR, MD5($sSQL), $tmp, 0, 10);
         }
echo "<br><br>"; return $tmp; }

« previous php.general (#237457) next »