system/library/cache/file.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Cache;
class File {
private $expire;
public function __construct($expire = 3600) {
$this->expire = $expire;
$files = glob(DIR_CACHE . 'cache.*');
if ($files) {
foreach ($files as $file) {
$time = substr(strrchr($file, '.'), 1);
if ($time < time()) {
if (file_exists($file)) {
unlink($file);
}
}
}
}
}
public function setExpire($expire = 3600){
$this->expire=$expire;
return $this;
}
public function get($key) {
$files = glob(DIR_CACHE . 'cache.' . preg_replace('/[^A-Z0-9\._-]/i', '', $key) . '.*');
if ($files) {
$handle = fopen($files[0], 'r');
flock($handle, LOCK_SH);
$data = fread($handle, filesize($files[0]));
flock($handle, LOCK_UN);
fclose($handle);
return json_decode($data, true);
}
return false;
}
public function set($key, $value) {
$this->delete($key);
$file = DIR_CACHE . 'cache.' . preg_replace('/[^A-Z0-9\._-]/i', '', $key) . '.' . (time() + $this->expire);
$handle = fopen($file, 'w');
flock($handle, LOCK_EX);
fwrite($handle, json_encode($value));
fflush($handle);
后面还有 34 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
