首先看看adodb提供的数据缓存功能: include(adodb.inc.php); # load code common to ADOdb $ADODB_CACHE_DIR = /usr/ADODB_cache; $conn = &ADONewConnection(mysql); # create a connection $conn->PConnect(‘localhost’,userid’,”,’agora’);# connect to MySQL, agora db $sql = ’select CustomerName, CustomerID from customers’; $rs = $conn->CacheExecute(15,$sql); ?> 如上,每次查询数据的时候,会把相应的结果序列化后保存到文件中,以后同样的查询语句就可以不用直接查询数据库,而是从缓存文件中获得。 再来看看Smarty提供的页面缓存功能: require(Smarty.class.php); $smarty = new Smarty; $smarty->caching = true; if(!$smarty->is_cached(‘index.tpl’)) { // No cache available, do variable assignments here. $contents = get_database_contents(); $smarty->assign($contents); } $smarty->display(‘index.tpl’); ?>