|
|
|
|
|
|
Thursday, July 29th, 2010
MySQL Cache Script |
|
|
|
|
|
. : : MySQL Cache Script |
|
|
This script cache's a variable or an array of variables for a specified amount of time in a MySQL table. Useful for pages that fetch data from other websites, so that you don't have to query the remote site every time you want data. Requires MySQL
 |
Explanations:
cache.php - The script page. Include it in the page you need caching with, then call its functions.
gpl.txt - A copy of the General Public License.
readme.txt - A quick readme file.
SQL.sql - The SQL table.
|
EXAMPLE:
<?
# Format:
# cache($id, $seconds, $data)
# $id is a unique indentifying string
# $seconds is the number of seconds you want to cache the data
# $data is what you want cached
include ("cache.php");
$cached = cache("animals");
if ($cached){ //CHECK IF IT'S ALREADY CACHED
$test = $cached;
echo "\n<br>CACHED DATA\n<br>";
}else{ //AQUIRE THE DATA, THEN CACHE IT
$test = array('turtle', "monkey", date("M j, Y", time()), "fish");
$cached = cache("animals", 60, $test); //CACHES FOR 60 SECONDS
echo "\n<br>FRESH DATA\n<br>";
} //DO WHATEVER TO THE DATA
//print_r(slash($test, 2));
print_r($test);
?>
-- DOWNLOAD -- 779 Downloads To Date
LASTEST UPDATES:
December 31, 2005
Changed format, so now you specify the length of time to cache it for at the time of caching.
No comments for this page. Feel free to be the first.
disclaimer:
the comments posted throughout my site are submitted by other users.
the things said are not endorsed by me, and do not represent my opinion.
|
|
|
|
|
|
|
|
|