<?php
 
require_once ('cache.class.php');
 
$cache = new cache();
 
/**
 
*         E X A M P L E
 
* Caching search details from any database
 
*/
 
$search_string = urldecode($_GET['s']);
 
 
// check if there is a cache for this search string
 
if (!$cache->read($result, "SEARCH_RESULTS_".$search_string)) {
 
 
    // if there is no cache, make a query and get the result
 
    $sql = "SELECT * FROM `results` WHERE `searched_str` LIKE '".addslashes($search_string)."'";
 
    $query = mysql_query($sql);
 
    $result = mysql_fetch_assoc($query);
 
 
    // cache the result for 1 hour (3600 sec)
 
    $cache->set($result, "SEARCH_RESULTS_".$search_string, 3600);
 
}
 
 
print "<pre>";
 
print_r ($result);
 
print "</pre>";
 
?>
 
 |