本地开发、开启文件缓存

This commit is contained in:
tlyong1992
2022-05-31 09:16:41 +08:00
parent a942a8fc31
commit 5ad1934366
3 changed files with 22 additions and 11 deletions

View File

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