play^ (29-07-11), StRiNg_MaStEr (19-06-11)
Usage : view example.phpThis class can be used to cache the output of PHP generated pages in files.
It can capture the output of a PHP script section and cache it by storing the output in files.
The output data is cached for a given timeout period. While the cache does not expire, the data is retrieved from the cache file.
The cache file path and the timeout period are configurable.
Simple usage :
I use this class to cache results from mysql query .PHP Code:<?php
include "nen.class.php";
$path = 'cache/'; // We set cache path ! Do not forget '/'
$cache_adv = new nencache;
$cache_name='page1'; //
$cache_time = '3600'; // (3600s = 1h :D )
if ($cache_adv -> start ($cache_name,$cache_time,$path)) {
///my normal page content here
$cache_adv -> build ($path);
}
?>
DO not include dinamic ads (e.g. from admob) in this code , because will be cached ..and is not good
An way to add dinamic ads in cached files can be the usage of some text e.g. [top_admob_ad]
and on output replace this with admob function :-?
If you have a better (or not) cache class , please post here .
Unamos los corazones,hoy todos somos multicolores!
play^ (29-07-11), StRiNg_MaStEr (19-06-11)
hw can i specify not cache this content
PHP Code:///content here will not be cached
if ($cache_adv -> start ($cache_name,$cache_time,$path)) {
///my normal page content here
/// all content from here will be cached
$cache_adv -> build ($path);
}
///content here will not be cached
Unamos los corazones,hoy todos somos multicolores!
Nice code
I hope i can implement it into my forum, but one hour seems to be to much for a dynamic site, 5 mins would be a better choice![]()
Just delete the cache file when you add something new.
<?php unlink('World/Europe/Romania.country'); ?>
u cn use memcache also![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks