编写定时任务定时向缓存中写入数据:
if($contents){
$file->cacheData('index_cron_cache',$contents);
}else{
file_put_contents('./logs/'.date('y-m-d').'.txt', "没有相关数据");
}
return;
数据的接口读取缓存数据:
$file = new File();
$data = $file->cacheData('index_cron_cache');
if($data){
return Response::show(200,"数据获取成功",$data);
}else{
return Response::show(400,"数据获取失败");
}
内容有参考暮课网视频《PHP开发APP接口》