jilin 发表于 2020-7-14 14:47:04

codeigniter 4 怎么使用redis

codeigniter 4 怎么使用redis

codes 发表于 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);
      }
}
页: [1]
查看完整版本: codeigniter 4 怎么使用redis