引入mongodb

This commit is contained in:
tlyong1992
2022-06-06 17:23:07 +08:00
parent 96a13170fd
commit 6c2d960fbb
3 changed files with 56 additions and 2 deletions

View File

@@ -1,9 +1,13 @@
import MemoryCache from './memory_cache'
import FileCache from './local_file_cache'
import MongoCache from './mongo_db_cache'
const enableCache = true
const enableMongoCache = true
let api
if (process.env.ENABLE_FILE_CACHE) {
if (enableMongoCache) {
api = MongoCache
} else if (process.env.ENABLE_FILE_CACHE) {
api = FileCache
} else {
api = MemoryCache
@@ -22,7 +26,7 @@ export async function getDataFromCache(key) {
if (JSON.stringify(dataFromCache) === '[]') {
return null
}
return dataFromCache
return MongoCache.getCache(key)
}
export async function setDataToCache(key, data) {