where($where) ->count(); $list = (new SystemFaq()) ->where($where) ->page($page, $limit) ->order($sort) ->select(); foreach ($list as &$v) { if ($v->parent_id == 0) { $v->parent_id = '最上级'; } else { $self = SystemFaqLogic::getTitleById($v->parent_id); $v->parent_id = $self; } } return [$count, $list]; } private static function getTitleById($parent_id) { $key = self::$CACHE_ID_KEY . $parent_id; if (Cache::has($key)) { return Cache::get($key); } $name = SystemFaqDao::getTitleById($parent_id); Cache::set($key, $name, 10 * 60); return $name; } public static function delTitleCache($parent_id) { $key = self::$CACHE_ID_KEY . $parent_id; Cache::delete($key); } public static function getTopList() { $key = self::$CACHE_LIST_KEY; if (Cache::has($key)) { return Cache::get($key); } $list = SystemFaqDao::getTopArrList(); array_push($list, ['id' => 0, 'title' => '最上级']); Cache::set($key, $list, 10 * 60); return $list; } public static function delCache() { $key = self::$CACHE_LIST_KEY; Cache::delete($key); } }