Files
NotionNext/lib/cache/memory_cache.js
2022-01-04 12:29:27 +08:00

13 lines
342 B
JavaScript

import cache from 'memory-cache'
import BLOG from 'blog.config'
const cacheTime = BLOG.isProd ? 10 : 120 * 60 // 120 minutes for dev,10 minutes for prod
export async function getCacheFromMemory (key, options) {
return cache.get(key)
}
export async function setCacheToMemory (key, data) {
await cache.put(key, data, cacheTime * 1000)
}