mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
Code🤣
This commit is contained in:
21
lib/cache/cache_manager.js
vendored
Normal file
21
lib/cache/cache_manager.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { getCacheFromFile, setCacheToFile } from '@/lib/cache/local_file_cache'
|
||||
import { getCacheFromMemory, setCacheToMemory } from '@/lib/cache/memory_cache'
|
||||
import BLOG from '@/blog.config'
|
||||
|
||||
export async function getDataFromCache (key) {
|
||||
let dataFromCache
|
||||
if (BLOG.isProd) {
|
||||
dataFromCache = await getCacheFromMemory(key)
|
||||
} else {
|
||||
dataFromCache = await getCacheFromFile(key)
|
||||
}
|
||||
return dataFromCache
|
||||
}
|
||||
|
||||
export async function setDataToCache (key, data) {
|
||||
if (BLOG.isProd) {
|
||||
await setCacheToMemory(key, data)
|
||||
} else {
|
||||
await setCacheToFile(key, data)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user