- /**
- * Read or set cache
- *
- * @access public
- * @param string $name Cache name
- * @param mixed $value cache content, null delete cache
- * @param string $path cache path
- * @return mixed
- */
- function cache($name, $value = , $path = )
- {
- return false; //During debugging phase, no caching is performed
- $path = empty($path) ? ROOT_PATH . /Runtime/Data/ : $path;
- $file = $path . $name . .php;
- if (empty($value)) {
- //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)); //The write cache name is the cache name, and the following array is the cache content
- cache(name); //Read the cache
- cache(name, null); //Delete 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 cache content, null delete cache* @param string $path cache path* @re...