比如这段代码public static function getBookBasicInfo($bookId, $isDel = 0)
{
$bookId = intval($bookId);
$isDel = intval($isDel);
$key = self::keyForBaseInfo($bookId);
$getFunc = function () use ($bookId, $isDel) {
$where = array(
'id' => $bookId,
'isdel' => $isDel,
);
$row = \MCore_Dao_DB::create()->select(self::$table, self::$baseFields, $where)->first();
return empty($row) ? null : $row;
};
return Cache::fetch($key, $getFunc);
}
7行到14行,回调方法在多个方法中都使用到了,有什么好的办法,将其抽出来,以免不必要的粘贴复制。