缓存优化
This commit is contained in:
tangly1024
2021-12-16 22:01:59 +08:00
parent 54026de51b
commit 6dc1794bdf
6 changed files with 80 additions and 27 deletions

View File

@@ -3,7 +3,8 @@ import { NotionAPI } from 'notion-client'
import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
export async function getPostBlocks (id, from) {
let pageBlock = await getDataFromCache('page_block_' + id)
const cacheKey = 'page_block_' + id
let pageBlock = await getDataFromCache(cacheKey)
if (pageBlock) {
console.log('[请求缓存]:', `from:${from}`, `id:${id}`)
return pageBlock
@@ -20,7 +21,7 @@ export async function getPostBlocks (id, from) {
}
if (pageBlock) {
await setDataToCache('page_block_' + id, pageBlock)
await setDataToCache(cacheKey, pageBlock)
}
return pageBlock
}