codeigniter 4 怎么使用redis
codeigniter 4 怎么使用redis $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);
}
}
页:
[1]