mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-09 15:10:39 +00:00
2
lib/cache/cache_manager.js
vendored
2
lib/cache/cache_manager.js
vendored
@@ -40,7 +40,7 @@ export async function getOrSetDataWithCustomCache(
|
|||||||
) {
|
) {
|
||||||
const dataFromCache = await getDataFromCache(key)
|
const dataFromCache = await getDataFromCache(key)
|
||||||
if (dataFromCache) {
|
if (dataFromCache) {
|
||||||
console.log('[缓存-->>API]:', key)
|
// console.log('[缓存-->>API]:', key) // 避免过多的缓存日志输出
|
||||||
return dataFromCache
|
return dataFromCache
|
||||||
}
|
}
|
||||||
const data = await getDataFunction(...getDataArgs)
|
const data = await getDataFunction(...getDataArgs)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export function getAllTags({
|
|||||||
const AllTagInfos = {}
|
const AllTagInfos = {}
|
||||||
// 遍历所有文章
|
// 遍历所有文章
|
||||||
allPosts.forEach(post => {
|
allPosts.forEach(post => {
|
||||||
post.tags.forEach(tag => {
|
post?.tags?.forEach(tag => {
|
||||||
// 如果标签已经存在
|
// 如果标签已经存在
|
||||||
if (AllTagInfos[tag]) {
|
if (AllTagInfos[tag]) {
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -8,17 +8,17 @@ import { deepClone, delay } from '../utils'
|
|||||||
import notionAPI from '@/lib/notion/getNotionAPI'
|
import notionAPI from '@/lib/notion/getNotionAPI'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文章内容
|
* 获取文章内容块
|
||||||
* @param {*} id
|
* @param {*} id
|
||||||
* @param {*} from
|
* @param {*} from
|
||||||
* @param {*} slice
|
* @param {*} slice
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function getPage(id, from = null, slice) {
|
export async function getPage(id, from = null, slice) {
|
||||||
|
const cacheKey = `page_content_${id}`
|
||||||
return await getOrSetDataWithCache(
|
return await getOrSetDataWithCache(
|
||||||
`page_content_${id}_${slice}`,
|
cacheKey,
|
||||||
async (id, slice) => {
|
async (id, slice) => {
|
||||||
const cacheKey = `page_block_${id}`
|
|
||||||
let pageBlock = await getDataFromCache(cacheKey)
|
let pageBlock = await getDataFromCache(cacheKey)
|
||||||
if (pageBlock) {
|
if (pageBlock) {
|
||||||
// console.debug('[API<<--缓存]', `from:${from}`, cacheKey)
|
// console.debug('[API<<--缓存]', `from:${from}`, cacheKey)
|
||||||
|
|||||||
Reference in New Issue
Block a user