PHP Operation Cache
Generated
Get
Delete
1 class file{2 private $_dir; 3 const ext= '. txt '; 4 public Function __consruct () {5 $this->_dir dirname (__file___). ' Files/'; 6} 7 Public Function CacheData ($key, value= ", $path =") {8 $filename = $this->_dir. $path. $key. Self::ext; 9 if ($value!== ") {//write value to cache//delete cache if (Is_null ($value)) {return @unlike ($filename) }10 $dir =dirname ($filename), one if (!is_dir ($dir)) {mkdir ($dir, 0777); 13}14 Return file_put_contents ($filename, Jsonencode ($value)), if (!is_file ($filename)) { return FALSE; }else{return Json_decode (File_get_content ($filename), true); }16}24 25} 26 27 28//Generate Cache $file = new Firl (), if ($file->cachedata (' Index_mk_cache ', $data)) {EC Ho "Success";}else (echo "false"; 35) 36//Get Cache
$file = new Firl (); if ($file->cachedata (' Index_mk_cache ')) {var_dump ($file->cahcedata (' Index_mk_cache ')); exit; echo "Success";} Else (echo "false";) Delete Cache
37