You are here: C97net • 5.11 Misc Functions
qEngine & Caching
qEngine support a database cache, called qCache. Caching is very easy with qCache.
1. First, store the cached contents by qcache_update:
function qcache_update ($id, $content)
$id = unique ID.
$content = cached content.
2. Then get the cached content from the database:
function qcache_get ($id)
$id = the unique ID.
Example 1
<?php
require './includes/user_init.php';
$cmd = post_param ('cmd');
// try to get the cache
$content = qcache_get ('mycache');
if (!$content)
{
// fill with usual code, including mysql query, etc
// to prove this is cached, we are using randomizer
// if it's not cached, randomizer should always be changed.
$sess = random_str(16).'-'.getmicrotime ();
$content = "<h1>This is a Content</h1>\n";
$content = "<p>It's now: $sess</p>\n";
// the store the content
qcache_update ('mycache', $content);
}
echo $content;
?>
There is no comment. Why not be the first?