Files
NotionNext/lib/cache/memory_cache.js
anime 148545cea9 feat(原生AI摘要功能支持缓存): 自定义缓存功能只支持memory,不支持文件缓存
(cherry picked from commit dd56dae44f7f555d9004e7d1f872085bded2cb86)
2024-12-29 00:21:37 +08:00

19 lines
484 B
JavaScript

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