I use mysqli in PHP 5 right now and want to start incorporating the use of memcache. I'm able to store something in memcache, but I'm not quite able to get things out.
I put data in with this:
   $db = new mysqli('host','user','password','database');
   $sql = ... <a SELECT statement>
   $result = $db->query($sql);
$memcache->set($memcache_key,$result,TRUE,86400) or die ("Failed to save data at the server");

The output of this:
   $cached_result = $memcache->get($memcache_key);
   var_dump($cached_result);

is this:
   object(mysqli_result)#2 (0) { }

So, shouldn't I be able to treat $cached_result as a mysqli result set? Shouldn't something like the following work (it doesn't)?
   $num_results = $cached_result->num_rows;

Should I massage $result into something else before sticking it into $memcache->set()?

Thanks in advance,
Josh

Reply via email to