Caching mysql results in cache table to be retrieved later
You can't store the query result resource directly in the cache table as it can't be serialised. Instead you should loop through that resource when you first run the expensive query, and cache an array of results, like so:

$q = db_query('expensive sql here');
$data = array();
while ($row = db_fetch_object($q)) {
  $data[] = $row;
}

cache_set('expensive_sql', $data, MY_CACHE_TABLE);


Then when you pick it up at the other end you can just loop through that array:

$cached_res_obj = cache_get("expensive_sql", MY_CACHE_TABLE);
$res            = $cached_res_obj-&gt;data;

foreach ($res as $row) {
  print_r($row);
}