feat(初步完成Redis缓存功能):

This commit is contained in:
anime
2025-01-05 01:57:19 +08:00
parent 442dd87828
commit ee7bbfc209
2 changed files with 44 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import BLOG from '@/blog.config'
import FileCache from './local_file_cache'
import MemoryCache from './memory_cache'
import RedisCache from './redis_cache'
/**
* 为减少频繁接口请求notion数据将被缓存
@@ -40,7 +41,9 @@ export async function delCacheData(key) {
* @returns
*/
function getApi() {
if (process.env.ENABLE_FILE_CACHE) {
if (process.env.REDIS_URL) {
return RedisCache
} else if (process.env.ENABLE_FILE_CACHE) {
return FileCache
} else {
return MemoryCache