mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-21 15:09:43 +00:00
feature:
标签加入颜色
This commit is contained in:
13
lib/cache/cache_manager.js
vendored
13
lib/cache/cache_manager.js
vendored
@@ -1,12 +1,18 @@
|
||||
import { getCacheFromFile, setCacheToFile } from '@/lib/cache/local_file_cache'
|
||||
import { getCacheFromMemory, setCacheToMemory } from '@/lib/cache/memory_cache'
|
||||
import BLOG from '@/blog.config'
|
||||
// 关闭本地缓存
|
||||
const enableCache = true
|
||||
|
||||
/**
|
||||
* 为减少频繁接口请求,notion数据将被缓存
|
||||
* @param {*} key
|
||||
* @returns
|
||||
* @param {*} key
|
||||
* @returns
|
||||
*/
|
||||
export async function getDataFromCache (key) {
|
||||
if (!enableCache) {
|
||||
return null
|
||||
}
|
||||
let dataFromCache
|
||||
if (BLOG.isProd) {
|
||||
dataFromCache = await getCacheFromMemory(key)
|
||||
@@ -17,6 +23,9 @@ export async function getDataFromCache (key) {
|
||||
}
|
||||
|
||||
export async function setDataToCache (key, data) {
|
||||
if (!enableCache) {
|
||||
return
|
||||
}
|
||||
if (BLOG.isProd) {
|
||||
await setCacheToMemory(key, data)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user