print

Caching with qCache

You are here: C97net5.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;
?>
Posted on: Aug-27-2010 at 07:00am
Last Updated: Jan-01-1970 at 07:00am

There is no comment. Why not be the first?

read more More Comments/Post Your Own

Account

Search

Tags

acp add all also any create default display don download easy echo etc features field file files folder form function includes information init kemana link list may module name need number own page php please qengine read require script set site skin time tpl url use user using version welcome