@@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
22import FileCache from './local_file_cache'
33import MemoryCache from './memory_cache'
44import RedisCache from './redis_cache'
5- import VercelCache from './vercel_cache'
5+ // import VercelCache from './vercel_cache'
66
77const cacheStats = {
88 hit : 0 ,
@@ -17,8 +17,6 @@ const isBuildPhase =
1717 process . env . npm_lifecycle_event === 'build' ||
1818 process . env . npm_lifecycle_event === 'export'
1919
20-
21-
2220const enableLocalCache = isBuildPhase || ! BLOG [ 'isProd' ]
2321const hasRedis = ! ! BLOG . REDIS_URL
2422
@@ -58,7 +56,7 @@ export async function getOrSetDataWithCustomCache(
5856 return inflightMap . get ( key )
5957 }
6058
61- // cacheLog('MISS', key, '缓存未命中,发起真实请求')
59+ cacheLog ( 'MISS' , key , '缓存未命中,发起真实请求' )
6260
6361 const promise = getDataFunction ( ...getDataArgs )
6462 . then ( async data => {
@@ -71,7 +69,7 @@ export async function getOrSetDataWithCustomCache(
7169 } )
7270 . catch ( err => {
7371 inflightMap . delete ( key )
74- // cacheLog('ERROR', key, err.message)
72+ cacheLog ( 'ERROR' , key , err . message )
7573 throw err
7674 } )
7775
@@ -125,7 +123,7 @@ export async function getDataFromCache(key, force) {
125123 console . warn ( `[Cache] ${ name } get failed key:${ key } ` , e . message )
126124 }
127125 }
128- cacheStats . miss ++
126+ cacheStats . miss ++
129127 return null
130128}
131129
@@ -143,8 +141,8 @@ export async function delCacheData(key) {
143141
144142function getCacheType ( ) {
145143 if ( hasRedis ) return 'redis'
146- if ( isVercelEnv ( ) ) return 'vercel'
147144 if ( isBuildPhase ) return 'file'
145+ // if (isVercelEnv()) return 'vercel'
148146 return 'memory'
149147}
150148
@@ -154,8 +152,10 @@ export function getApi() {
154152 switch ( type ) {
155153 case 'redis' :
156154 return RedisCache
157- case 'vercel' :
158- return VercelCache
155+ // case 'vercel':
156+ // VercelCache 目前不稳定(有大小限制),先注释掉
157+ // return VercelCache
158+ // 文件速度和内存消耗存疑
159159 case 'file' :
160160 return FileCache
161161 default :
@@ -170,9 +170,9 @@ function getCacheChain() {
170170 chain . push ( { name : 'redis' , api : RedisCache } )
171171 }
172172
173- if ( isVercelEnv ( ) ) {
174- chain . push ( { name : 'vercel' , api : VercelCache } )
175- }
173+ // if (isVercelEnv()) {
174+ // chain.push({ name: 'vercel', api: VercelCache })
175+ // }
176176
177177 if ( isBuildPhase || ! BLOG . isProd ) {
178178 chain . push ( { name : 'file' , api : FileCache } )
0 commit comments