Ben veritabanı yükü azaltmak için bir önbellek sistemi rulo çalışıyorum.
I want to be able to compare timestamps of the last updated time the flat file was updated to make sure it's not too long ago that the file was last updated.
Here's the code:
$cache_file = $_GET[ 'page_id' ] . '.html';
function cache() {
// Here i want to get the timestamp of the file that was previously cached,
// if it exists.
// If the file doesn't exist, create it.
// If it does exist, check last modified time, if it's too long ago, then overwrite
// the file.
$ob = ob_get_contents();
file_put_contents( $cache_file, $ob );
}
function loadFromCache( $page_id ) {
$file_name = $page_id . '.html';
if( ! file_exists( $file_name ) ) {
return false;
}
readfile( $file_name );
return true;
}
Teşekkür ederim.