mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-31 23:16:54 +00:00
搜索、缓存 、页面
This commit is contained in:
8
lib/cache/memory_cache.js
vendored
8
lib/cache/memory_cache.js
vendored
@@ -3,14 +3,14 @@ import BLOG from 'blog.config'
|
||||
|
||||
const cacheTime = BLOG.isProd ? 10 * 60 : 120 * 60 // 120 minutes for dev,10 minutes for prod
|
||||
|
||||
export async function getCacheFromMemory (key, options) {
|
||||
return cache.get(key)
|
||||
export async function getCacheFromMemory(key, options) {
|
||||
return await cache.get(key)
|
||||
}
|
||||
|
||||
export async function setCacheToMemory (key, data) {
|
||||
export async function setCacheToMemory(key, data) {
|
||||
await cache.put(key, data, cacheTime * 1000)
|
||||
}
|
||||
|
||||
export async function delCacheFromMemory (key) {
|
||||
export async function delCacheFromMemory(key) {
|
||||
await cache.del(key)
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ export async function getNotionPageData({ pageId, from }) {
|
||||
const cacheKey = 'page_block_' + pageId
|
||||
const data = await getDataFromCache(cacheKey)
|
||||
if (data) {
|
||||
console.log('[请求缓存]:', `from:${from}`, `id:${pageId}`)
|
||||
console.log('[请求缓存]:', `from:${from}`, `root-page-id:${pageId}`)
|
||||
return data
|
||||
}
|
||||
const pageRecordMap = await getPageRecordMapByNotionAPI({ pageId, from })
|
||||
|
||||
Reference in New Issue
Block a user