Hello, I'm currently attempting to implement APC caching as a datastore in my web application.
Currently, the system retrieves data directly from the MySQL database, and requires a database call per request.
I'm currently attempting to change this by prepopulating the cache with data which is intercepted and served from the cache at each request.
Here's the current method:
if(!empty($_GET['id'])){
$app = $db->real_escape_string($_GET['id']);
$result = $db->query("SELECT * FROM pages_content WHERE id = $app");
$rawdata = $result->fetch_assoc();
}
Data is presented by output by:
$title = stripslashes($rawdata['title']);
$meta['keywords'] = stripslashes($rawdata['htmlkeywords']);
$meta['description'] = stripslashes($rawdata['htmldesc']);
$subs = stripslashes($rawdata['subs']);
$pagecontent = "<article>".stripslashes($rawdata['content'])."</article>";
What I need the prepopulating script to do is for each row of data in the data table, cache each row's data. The serving script would then be able to pluck the data from the cache as an when required, using something such as apc_fetch('[columname][id]')
.
How could I devise this?
I assume I'd need to serialize the data?