php - Can i store mysql result in apc cache ? -


consider sample code :

    $storyid = 1;     $detailscache = 'details'.$storyid;     if(!apc_exists($detailscache)){     $phases_details = <<<sql             select stp.stp_id,                 stp.stp_name,                 stp.stp_position,                 story_phase stp                stp.stp_stl_id = $storyid     sql;    $resultdetails = helpers::execute_query($phases_details,"get phase details failed."); **// cant cache result here apc_store($detailscache, $phases_details);** } $result_phases_details = apc_fetch($detailscache);  while($row = mysql_fetch_assoc($result_phases_details)){ // logic } 

any better way cache result ?

assuming mysql result resource (which seems based on later use of mysql_fetch_assoc), cannot stored via apc. however, if read out result php data structures first, can store in apc later retrieval.

$resultdetails = helpers::execute_query($phases_details,"get phase details failed."); $results = array(); while ($row = mysql_fetch_assoc($resultdetails)) {   $results[] = $row; } apc_store($detailscache, $results);  // retrieval: $results = apc_fetch($detailscache); foreach ($results $row) {   // logic... } 

Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -