This commit is contained in:
蒋小陌 2024-10-15 11:14:11 +08:00
parent 6acb40da3c
commit bf6cebe31a

View File

@ -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);