& Lt ;? Php & nbsp;/** & nbsp; * read or set Cache & nbsp; * @ access & nbsp; public & nbsp; * @ param & nbsp; & nbsp; string & nbsp; $ name & nbsp; cache name & nbsp; * @ param & nbsp; mixed & nbsp; & n
-
- /**
- * 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
- ?>