mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-04 15:10:23 +00:00
feature:
缓存优化
This commit is contained in:
@@ -11,7 +11,8 @@ import { getPostBlocks } from '@/lib/notion/getPostBlocks'
|
||||
*/
|
||||
export async function getNotionPageData ({ pageId = BLOG.notionPageId, from }) {
|
||||
// 尝试从缓存获取
|
||||
const data = await getDataFromCache('page_record_map_' + pageId)
|
||||
const cacheKey = 'page_record_map_' + pageId
|
||||
const data = await getDataFromCache(cacheKey)
|
||||
if (data) {
|
||||
console.log('[请求缓存]:', `from:${from}`, `id:${pageId}`)
|
||||
return data
|
||||
@@ -19,7 +20,7 @@ export async function getNotionPageData ({ pageId = BLOG.notionPageId, from }) {
|
||||
const pageRecordMap = await getPageRecordMapByNotionAPI({ pageId, from })
|
||||
// 存入缓存
|
||||
if (pageRecordMap) {
|
||||
await setDataToCache('page_record_map', pageRecordMap)
|
||||
await setDataToCache(cacheKey, pageRecordMap)
|
||||
}
|
||||
return pageRecordMap
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user