Pear DB and memcached

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;

 }


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux