文件缓存的php类库.zip

时间:2022-07-31 04:49:11
【文件属性】:
文件名称:文件缓存的php类库.zip
文件大小:1KB
文件格式:ZIP
更新时间:2022-07-31 04:49:11
类库下载-文件缓存的php类库 <?php class CacheLayer{   protected $root = "";   protected $cache = "";   protected $key = "";   protected $life = 0;   public function __construct($key, $root = "/cachelayer"){     $this->root = $_SERVER["DOCUMENT_ROOT"].$root;     $this->key = $key;   }   public function expired($life_span){     $this->life = $life_span;     $file = $this->root."/".$this->key.".cachelayer";     if(is_file($file)){       $mtime = filemtime($file);       return (time() >= ($mtime   $this->life));     }else{       return true;     }   }   public function put($content){     $file = $this->root."/".$this->key.".cachelayer";     if(!is_dir(dirname($this->root))){       return false;     }     $this->delete();     $content = json_encode($content);     return (bool)file_put_contents($file, $content);   }   public function get(){     $file = $this->root."/".$this->key.".cachelayer";     if(is_file($file)){       return json_decode(file_get_contents($file), true);     }     return array();   }   public function delete(){     $file = $this->root."/".$this->key.".cachelayer";     if(is_file($file)){       unlink($file);       return true;     }     return false;   } } ?>这是一份很好用的PHP缓存类库,需要的朋友可以下载使用,可以通过文件缓存,大大缓解数据库的压力
【文件预览】:
文件缓存的php类库
----php中文网下载站.url(114B)
----code.php(1KB)
----php中文网免费下载站.txt(219B)

网友评论