From bf6cebe31adc2e34b9348fe8d612cf8c48301bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=B0=8F=E9=99=8C?= Date: Tue, 15 Oct 2024 11:14:11 +0800 Subject: [PATCH] 1111 --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index 79a505a..f9cf85e 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,8 @@ const viewsInfo = { cacheHit: 0, // API调用次数 apiCall: 0, + // 缓存调用次数 + cacheCall: 0, }; // 默认端口号和 API 地址 @@ -236,6 +238,11 @@ const fetchAndServe = (data, tempCacheContentFile, cacheContentFile, res) => { // 从缓存中读取数据并返回 const serveFromCache = (cacheMetaFile, cacheContentFile, res) => { + + // 增加缓存调用次数 + viewsInfo.cacheCall++; + + const cacheData = JSON.parse(fs.readFileSync(cacheMetaFile, 'utf8')); const readStream = fs.createReadStream(cacheContentFile);