Php implements the file cache function code .? Php *** READ or set cache ** @ accesspublic * @ paramstring $ name cache name * @ parammixed $ value cached content, null delete cache * @ paramstring $ path cache path * @ re
- /**
- * Read or set cache
- *
- * @ Access public
- * @ Param string $ name cache name
- * @ Param mixed $ value: cached content. null: deletes the cache.
- * @ Param string $ path: cache path
- * @ Return mixed
- */
- Function cache ($ name, $ value =, $ path =)
- {
- Return false; // In The debugging stage, no cache is performed.
- $ Path = empty ($ path )? ROOT_PATH./Runtime/Data/: $ path;
- $ File = $ path. $ name.. php;
- If (empty ($ value )){
- // The cache does not exist.
- If (! Is_file ($ file )){
- Return false;
- }
- // Delete cache
- If (is_null ($ value )){
- Unlink ($ file );
- Return true;
- }
- $ Data = include $ file;
- Return $ data;
- }
- $ Value = var_export ($ value, true );
- $ Value =" ";
- Return file_put_contents ($ file, $ value );
- }
- // Function call
- Cache (name, array (a, B, c); // write the cache name as the cache name, and the following array is the cached content
- Cache (name); // read the cache
- Cache (name, null); // deletes the cache
- ?>
Http://www.bkjia.com/PHPjc/486194.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486194.htmlTechArticle? Php/*** READ or set cache ** @ access public * @ param string $ name cache name * @ param mixed $ value cached content, null delete cache * @ param string $ path cache path * @ re...