缓存优化

This commit is contained in:
tangly1024
2022-01-27 13:58:49 +08:00
parent 44c698fd4d
commit 63e39fa2a8
6 changed files with 26 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import { getCacheFromMemory, setCacheToMemory } from '@/lib/cache/memory_cache'
// import { getCacheFromFile, setCacheToFile } from './local_file_cache'
import { getCacheFromMemory, setCacheToMemory, delCacheFromMemory } from '@/lib/cache/memory_cache'
// import { getCacheFromFile, setCacheToFile, delCacheFromFile } from './local_file_cache'
const enableCache = true // 生产环境禁用
/**
@@ -24,3 +24,10 @@ export async function setDataToCache (key, data) {
}
await setCacheToMemory(key, data)
}
export async function delCacheData (key) {
if (!enableCache) {
return
}
await delCacheFromMemory(key)
}