我正在尝试为我的应用设置缓存。 我的问题是,当我试图使用它时,我得到错误500。 这是我的代码:
<?php
include_once '/var/www/libs/mainCache/fatfree-master/lib/base.php';
class CacheManager
{
private $cache;
private $isDebug;
const GYM_LIST = "gym_list";
const CHALLENGES_LIST = "challnges_list";
function __construct($isDebug = false)
{
$this->cache = \Cache::instance();
$this->isDebug = $isDebug;
$folder = $this->isDebug ? "/var/www/soFitTest/cache/" : "/var/www/soFit/cache/";
$this->cache->load(true, "folder=".$folder);
}
public function exists($id)
{
return $this->cache->exists($id);
}
public function set($id, $value)
{
return $this->cache->set($id, $value);
}
public function get($id)
{
return $this->cache->get($id);
}
public function clear($id)
{
return $this->cache->clear($id);
}
}
当我运行我的代码时:
$cacheManager = new CacheManager(true);
$gmyList = $cacheManager->get(CacheManager::GYM_LIST);
if($gmyList)
{
$result = $gmyList;
$result["cache"] = "true";
}
else
{
$result = $gymManager->getGymsList();
$result["cache"] = "false";
$cacheManager->set(CacheManager::GYM_LIST, $result);
}
我明白了:
<!DOCTYPE html>
<html>
<head>
<title>500 Internal Server Error</title>
<style>code{word-wrap:break-word;color:black}.comment,.doc_comment,.ml_comment{color:dimgray;font-style:italic}.variable{color:blueviolet}.const,.constant_encapsed_string,.class_c,.dir,.file,.func_c,.halt_compiler,.line,.method_c,.lnumber,.dnumber{color:crimson}.string,.and_equal,.boolean_and,.boolean_or,.concat_equal,.dec,.div_equal,.inc,.is_equal,.is_greater_or_equal,.is_identical,.is_not_equal,.is_not_identical,.is_smaller_or_equal,.logical_and,.logical_or,.logical_xor,.minus_equal,.mod_equal,.mul_equal,.ns_c,.ns_separator,.or_equal,.plus_equal,.sl,.sl_equal,.sr,.sr_equal,.xor_equal,.start_heredoc,.end_heredoc,.object_operator,.paamayim_nekudotayim{color:black}.abstract,.array,.array_cast,.as,.break,.case,.catch,.class,.clone,.continue,.declare,.default,.do,.echo,.else,.elseif,.empty.enddeclare,.endfor,.endforach,.endif,.endswitch,.endwhile,.eval,.exit,.extends,.final,.for,.foreach,.function,.global,.goto,.if,.implements,.include,.include_once,.instanceof,.interface,.isset,.list,.namespace,.new,.print,.private,.public,.protected,.require,.require_once,.return,.static,.switch,.throw,.try,.unset,.use,.var,.while{color:royalblue}.open_tag,.open_tag_with_echo,.close_tag{color:orange}.ini_section{color:black}.ini_key{color:royalblue}.ini_value{color:crimson}.xml_tag{color:dodgerblue}.xml_attr{color:blueviolet}.xml_data{color:red}.section{color:black}.directive{color:blue}.data{color:dimgray}
</style>
</head>
<body>
<h1>Internal Server Error</h1>
<p>mkdir(): Permission denied</p>
</body>
</html>
我的文件夹设置为完全权限: