Phalcon:backCache 不起作用
Phalcon: backCache does not work
我尝试缓存数据,但脚本总是向数据库发出请求
public static function getByCitiesIDs(array $ids): array
{
$di = Di::getDefault();
/** @var Backend $cache */
$cache = $di->get('backCache');
$key = 'get_flights_by_cities:' . md5(json_encode($ids));
$result = $cache->get($key);
if ($result === null) {
$result = RequestToDB();
$cache->save($key, $result, 36000);
}
return $result;
}
我做错了什么?
Phalcon 无法写入目录。检查您的系统写入权限。授予服务器(Apache 或其他)写入目录的权限。
我尝试缓存数据,但脚本总是向数据库发出请求
public static function getByCitiesIDs(array $ids): array
{
$di = Di::getDefault();
/** @var Backend $cache */
$cache = $di->get('backCache');
$key = 'get_flights_by_cities:' . md5(json_encode($ids));
$result = $cache->get($key);
if ($result === null) {
$result = RequestToDB();
$cache->save($key, $result, 36000);
}
return $result;
}
我做错了什么?
Phalcon 无法写入目录。检查您的系统写入权限。授予服务器(Apache 或其他)写入目录的权限。