|
发表于 2021-5-27 11:08:27
|
显示全部楼层
$cacheKey = 'goods:' . $goodsd;
$cache = \Config\Services::cache();
$data = $cache->get($cacheKey);
if (!$data) {
$db = \Config\Database::connect();
$data = $db->query("SELECT * FROM goods WHERE id=? AND is_delete = 0 LIMIT 1", [$goodsId])->getRowArray();
if ($data) {
$cache->save($cacheKey, $data);
}
} |
|