<?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 캐싱 라이브러리입니다. 필요한 친구는 다운로드하여 사용할 수 있습니다. 파일 캐싱을 통해 데이터베이스에 대한 부담을 크게 줄일 수 있습니다.
이 사이트의 모든 리소스는 네티즌이 제공하거나 주요 다운로드 사이트에서 재인쇄되었습니다. 소프트웨어의 무결성을 직접 확인하십시오! 이 사이트의 모든 리소스는 학습 참고용으로만 사용됩니다. 상업적 목적으로 사용하지 마시기 바랍니다. 그렇지 않으면 모든 결과에 대한 책임은 귀하에게 있습니다! 침해가 있는 경우 당사에 연락하여 삭제하시기 바랍니다. 연락처: admin@php.cn
관련 기사

29Jul2016
http://zikao.hneao.cn/net/:http://zikao.hneao.cn/net/ 신원 확인을 위한 php auth_http 클래스 라이브러리: 다음과 같이 코드를 복사합니다: "mysql://root:1981427@localhost/test", //데이터베이스 연결 문자열 'table'=>"tablename1", //테이블 이름' 사용자 이름

25Jul2016
구성 파일을 읽기 위한 PHP 클래스 PHP는 ini, yaml, xml 구성 파일 정보를 읽습니다.

29Jul2016
도서관 관리 시스템 활용 사례 다이어그램: 도서관 관리 시스템 활용 사례 다이어그램 도서관 관리 프로그램(1): 이 수준의 프로그램에서 사용하는 데이터 테이블 구조: # ------ --- --------------------- # # 데이터 테이블 구조 'author' # CREATE TABLE 작성자 ( author_id int (6) DEFAULT '0' NOT NULL auto_increment, first_name varchar(20)

29Jul2016
도서관 관리 시스템 소스 코드: 도서관 관리 시스템 소스 코드 php 무작위 인증 코드 생성 이미지 코드: 다음과 같이 코드를 복사합니다:


Hot Tools

종속성 주입 컨테이너용 PHP 라이브러리
종속성 주입 컨테이너용 PHP 라이브러리

50개의 뛰어난 클래식 PHP 알고리즘 모음
클래식 PHP 알고리즘, 훌륭한 아이디어를 배우고 사고력을 확장하세요

이미지 최적화를 위한 작은 PHP 라이브러리
이미지 최적화를 위한 작은 PHP 라이브러리
