perf(使用缓存优化): 复杂的数据转换函数使用缓存优化

This commit is contained in:
anime
2025-01-02 20:45:18 +08:00
parent 2766cb8d3b
commit b563744e24
2 changed files with 26 additions and 34 deletions

View File

@@ -66,13 +66,14 @@ export async function getGlobalData({
*/
export async function getSiteDataByPageId({ pageId, from }) {
// 获取NOTION原始数据此接支持mem缓存。
const pageRecordMap = await getPage(pageId, from)
return await getOrSetDataWithCache(
`site_data_${pageId}`,
converNotionToSiteDate,
async (pageId, from) => {
const pageRecordMap = await getPage(pageId, from)
return converNotionToSiteDate(pageId, from, deepClone(pageRecordMap))
},
pageId,
from,
deepClone(pageRecordMap)
from
)
}