include/chajian/cacheChajian.php

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php 
/**
*	缓存,目前是使用磁盘文件存储
*/
class cacheChajian extends Chajian{
	
	private $dirvie = 'file'; //redis,file
	
	/**
	*	设置缓存
	* 	$time 缓存时间(秒)
	*/
	public function set($key, $data, $time=0)
	{
		$this->del($key); //删除原来的
		$sarr['key']  = $this->getkey($key);
		$sarr['data'] = $data;
		if($time>0){
			$time = time()+$time;
		}else{
			$time = 0;
		}
		$sarr['time'] = $time;
		if($time>0)$sarr['timedt'] = date('Y-m-d H:i:s', $time);
		$sarr['url']  = $this->rock->nowurl();
		$this->delexpire();
		return $this->rock->createtxt($this->getpath($key, $time, 1), json_encode($sarr));
	}
	
	private function getkey($key)
	{
		return ''.QOM.''.$key.'';
	}
	
	private function getpath($key, $time=0, $lx=0)
	{
		$key = $this->getkey($key);
		$ske = '';
		if($time>0)$ske='_'.$time.'';
		
		if($lx==0)return ''.ROOT_PATH.'/'.UPDIR.'/cache/'.md5($key).''.$ske.'';
		return ''.UPDIR.'/cache/'.md5($key).''.$ske.'';
	}
	
	//获取文件名
	private function getpaths($key)
	{
		$key = $this->getkey($key);
		$file= ''.ROOT_PATH.'/'.UPDIR.'/cache/'.md5($key).'';
		$bar = glob(''.$file.'*');
		if(is_array($bar))foreach($bar as $k=>$fil1){
			if($k==0){
				$file = $fil1;
			}else{
				unlink($fil1);
			}
		}
		return $file;
	}
	
后面还有 63 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。