<?php
/*
* ClassName : Cache
* Version : 1.0
* Author : 翔天
* Description : 文件缓存类,支持数组缓存
* Link : http://www.yaayee.net/
* E-mail : 6770386@qq.com
* License : 本程序是开源的,你可以运用于各种开发。你可以根据需要修改程序主体,但请保留以上版本信息,谢谢!
*/
/*
功能:create()为创建缓存;remove()删除缓存;getcreatetime()获取缓存创建时间;getcache()获取缓存内容
实例:
$cache=new Cache('/cache_date/','inc'); //初始化,配置缓存目录,缓存文件扩展名,可以为任意可读取的文件类型
$cname='test';
$ccontent='testcontent';
$cache->create($cname,$ccontent); //保存单个缓存
$cname_arr=array('test1','test2','test3');
$ccontent_arr=array('testcontent1','testcontent2','testcontent3');
$cache->create($cname_arr,$ccontent_arr); //保存多个缓存
$cname_arr=array('test_arr1','test_arr2');
$ccontent_arr=array(array('content_arr_1_1','content_arr_1_2'),array('content_arr_2_1','content_arr_2_1'));
$cache->create($cname_arr,$ccontent_arr); //保存多个数组缓存
$cname=$cache->getcache('test'); //获取单个缓存
$ccontent_arr=$cache->getcache($cname_arr); //获取多个缓存
*/
class Cache{
var $cachepatch;
var $ftype;
function Cache($cachepatch,$ftype){
$cp=$_SERVER['DOCUMENT_ROOT'].$cachepatch;
$this->ftype=$ftype;
if (!is_dir($cp)){
mkdir($cp,0777);
}
$this->cachepatch=$cp;
}
//创建缓存:$cachename为缓存名称,$content为缓存内容,可以为array类型
function create($cachename,$content){
if (is_array($cachename)){
foreach ($cachename as $k=>$v){
if (file_exists($cachefile)){
@unlink($cachefile);
}
if ($this->ftype=='php' or $this->ftype=='inc'){
if (is_array($content[$k])){
$content[$k]="<?php\n$".$v."=".var_export($content[$k],true).";\n?>";
/*
* ClassName : Cache
* Version : 1.0
* Author : 翔天
* Description : 文件缓存类,支持数组缓存
* Link : http://www.yaayee.net/
* E-mail : 6770386@qq.com
* License : 本程序是开源的,你可以运用于各种开发。你可以根据需要修改程序主体,但请保留以上版本信息,谢谢!
*/
/*
功能:create()为创建缓存;remove()删除缓存;getcreatetime()获取缓存创建时间;getcache()获取缓存内容
实例:
$cache=new Cache('/cache_date/','inc'); //初始化,配置缓存目录,缓存文件扩展名,可以为任意可读取的文件类型
$cname='test';
$ccontent='testcontent';
$cache->create($cname,$ccontent); //保存单个缓存
$cname_arr=array('test1','test2','test3');
$ccontent_arr=array('testcontent1','testcontent2','testcontent3');
$cache->create($cname_arr,$ccontent_arr); //保存多个缓存
$cname_arr=array('test_arr1','test_arr2');
$ccontent_arr=array(array('content_arr_1_1','content_arr_1_2'),array('content_arr_2_1','content_arr_2_1'));
$cache->create($cname_arr,$ccontent_arr); //保存多个数组缓存
$cname=$cache->getcache('test'); //获取单个缓存
$ccontent_arr=$cache->getcache($cname_arr); //获取多个缓存
*/
class Cache{
var $cachepatch;
var $ftype;
function Cache($cachepatch,$ftype){
$cp=$_SERVER['DOCUMENT_ROOT'].$cachepatch;
$this->ftype=$ftype;
if (!is_dir($cp)){
mkdir($cp,0777);
}
$this->cachepatch=$cp;
}
//创建缓存:$cachename为缓存名称,$content为缓存内容,可以为array类型
function create($cachename,$content){
if (is_array($cachename)){
foreach ($cachename as $k=>$v){
if (file_exists($cachefile)){
@unlink($cachefile);
}
if ($this->ftype=='php' or $this->ftype=='inc'){
if (is_array($content[$k])){
$content[$k]="<?php\n$".$v."=".var_export($content[$k],true).";\n?>";

