Caching technology:
1. Static caching
Static files stored on disk, with PHP generated data into static files
2.Memcache and Redio Cache
The cache is primarily designed to reduce server stress.
PHP Operation Cache
1. Generating the cache
2. Get the cache
3. Delete Cache
<?PHPclass File{ Private $_dir; ConstEXT = '. txt '; Public function__construct () {$this-_dir =dirname(__file__).‘ /files ';//the folder where the cache directory is stored by default } Public functionCacheData ($k,$v= ",$path= ' '){ $filename=$this->_dir.$path.$k. Self::EXT; if($v!== ') {//write $v value to cache if(Is_null($v)){ return@unlink($filename); } $dir=dirname($filename); if(!Is_dir($dir)){//determine if a directory exists mkdir($dir, 0777);//does not exist then create the directory } return file_put_contents($filename, Json_encode ($v)); } if(!Is_file($filename)){ return false; }Else{ returnJson_decode (file_get_contents($filename),true); } } }
The test code is as follows:
<?PHPinclude('./7.php '); //test the XML data $data=Array( ' id ' = 1, ' name ' = ' lisi ', ' type ' = =Array(1,7,89,Array(' 5 ', ' A ', ' d ', ' d ')) ); $file=New File(); //The $data here means that if the value exists, the cache is opened and the cache is generated if it does not exist . if($fileCacheData (' Index_mk_cache '/*, $data*/,NULL)){ //Var_dump ($file->cachedata (' Index_mk_cache ')); exit; Echo"Success"; }Else{ Echo"Error"; }
Kill lui lei Dog---PHP Development App Interface---5 (Core technology caching technology)