<?php$info=s ("name", "Lizhaoyao"), $name =s ("name"), Var_dump ($name), function S ($key, $value = ", $cache _time=86400 { $md =md5 ($key);//Encrypt name by MD45 hash $dir = "./cache/";//define Cache Storage Path folder if (!is_dir ($dir)) { mkdir ($dir, ' 0777 ');//First detect if the folder exists } $file _name= $dir. $md; if (empty ($value)) { //to take the value out if (file_exists ($file _name)) { $cont =file_get_contents ($ file_name); Return Unserialize ($cont); } else{ echo ""; } } else { //If the assignment is null, the cache is deleted if ($value ===null) { return unlink ($file _name); } To be stored in $data [' Value ']= $value; $data [' Deadline ']=time () + $cache _time; Return file_put_contents ($file _name,serialize ($data));} ? >
Use this code to customize the read and use of a S method for caching
Customizing using S Caching method