I'm trying to use memcache but I'm stuck on a small part. I've got a function that gives in result an array of several things (most of them being strings), and one of them is the result of the mysql_query() function. Here is how I am trying to unserialize:
$posts_count = my query;
/* MEMCACHE KEY GEN*/
$memcache_key = md5($posts);
$pagination = memcache_get($memcache, $memcache_key);
if($pagination==NULL) {
echo 'NOT CACHED';
$pagination = (the function that will call mysql_query)
//SAVE A SERIALIZED VERSION OF THE ARRAY
$memcache->set($memcache_key, serialize($pagination), 0, 3600);
}
else {
$pagination = unserialize($pagination);
}
//THIS IS ONLY THE RESULT OF mysql_query!!!
$posts = $pagination[result];
while($var = mysql_fetch_array($posts)) { ... stuffs here }
Any idea on how to "save" this result of mysql_query before the mysql_fetch_array? Or any idea how to use memcache to cache the whole while loop?