标签加入颜色
This commit is contained in:
tangly1024
2021-11-30 17:48:57 +08:00
parent f5739dc51a
commit 1e24789a24
16 changed files with 217 additions and 156 deletions

View File

@@ -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 {