Php Cache technology instance. Php Cache technology example the php Cache technology mentioned in this article is to generate a temporary cache file for data and save it to the hard disk, then, delete the cache file based on the time set by the cache file to generate another php Cache technology instance. This article describes the php Cache technology that generates a temporary cache file and saves it to the hard disk, then, delete the cached file and generate a new cache file based on the time set for the cached file.
Php Tutorial cache technology example
The php Cache technology mentioned in this article is to generate a temporary cache file for data and save it to the hard disk. then, delete the cache file according to the time set by the cache file to generate a new cache file again.
*/
$ Filename = 'cachefile. php ';
$ Str = 'echo "bb ";';
If (is_file ($ filename ))
{
$ Tmp = readcache ($ filename );
}
Else
{
Createcache ($ filename, $ str );
}
// Write the cached file
Function createcache ($ filename, $ str)
{
If ($ str = '') {return false ;}
$ Fp = fopen ($ filename, "w +") or die ('The cache directory is not possible. set/www. bKjia. c0m/cache to writable! ');
If (! Fwrite ($ fp, $ str ))
{
Echo 'the cache file cannot be created! ';
Exit;
}
Fclose ($ fp );
}
// Read the cached file
Function readcache ($ filename)
{
$ Str = file_get_contents ($ filename );
If ($ str = "")
{
Echo "an error occurred while reading the cached file! ";
Exit;
}
Return $ str;
}
/*
Original site article, reprinted with source http://www.bKjia. c0m/phper/php.html
*/
Http://www.bkjia.com/PHPjc/632041.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632041.htmlTechArticlephp cache technology instance this article will talk about the php Cache technology is to generate a temporary cache file to save the data to the hard disk, and then according to the cache file set time to delete the cache file again...