File size: 446 Bytes
1b72d7e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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) {
await cache.put(key, data, cacheTime * 1000)
}
export async function delCache(key) {
await cache.del(key)
}
export default { getCache, setCache, delCache }
|