| 
<?php
 /* the catalogue cache has to have chmod 666 or 777 */
 
 /*========================*\
 
 * cache_TS
 * Written by: AS
 * Mialto: [email protected]
 * Date: 2007-08-23
 * Cache: multiSystem cache SQL and PHP code
 * Version: 1
 * Licencia: Lesser General Public License (LGPL)
 *
 * Copyright (C) 2007 Jacek Wloka
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 
 \*========================*/
 
 function getmicrotime(){
 list($usec, $sec) = explode(" ",microtime());
 return ((float)$usec + (float)$sec);
 }
 
 $host_sql = 'localhost'; /* host */
 $user_sql = 'root'; /* user */
 $pass_sql = 'krasnal'; /* password */
 $db_sql = 'database1'; /* database */
 
 $connect_sql = @mysql_connect($host_sql, $user_sql, $pass_sql);
 if (!$connect_sql) {exit('the lack of the connection...');}
 if (!mysql_select_db($db_sql)) {exit('the lack of the database...');}
 
 include ('cache_ts.php');
 
 $cache = &new cache_TS();
 
 // the question sql
 $q = 'SELECT * FROM `test`';
 
 $time_start = getmicrotime();
 
 /******************************************************************************\
 
 check_cache('sql $q', second=300, dir='./cache')
 
 \******************************************************************************/
 
 if ($cache->check_cache($q, 300))
 {
 $cache->start_cache();
 
 $q_sql = mysql_query($q);
 while ($row = mysql_fetch_array($q_sql))
 {
 echo '<hr /><br />';
 printf ("ID: %s  Data: %s", $row[ID], $row[TEXT]);
 }
 
 $cache->end_cache();
 }
 else
 {
 $cache->contents_cache();
 }
 
 mysql_close($connect_sql);
 
 $time_end = getmicrotime();
 $time = $time_end - $time_start;
 echo '<hr /><br />Generate in '.$time.' s. <a href="?">refresh</a>';
 
 ?>
 |