From 4ae023afd703d30bddadeb99be46409a6af7e90f Mon Sep 17 00:00:00 2001 From: wood chen <95951386+woodchen-ink@users.noreply.github.com> Date: Mon, 9 Sep 2024 21:44:36 +0800 Subject: [PATCH] Update app.js --- nodejs/app.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nodejs/app.js b/nodejs/app.js index 80c5168..9b67401 100644 --- a/nodejs/app.js +++ b/nodejs/app.js @@ -1,6 +1,6 @@ import express from 'express'; import fetch from 'node-fetch'; -import LRU from 'lru-cache'; +import { LRUCache } from 'lru-cache'; // 使用命名导入 import compression from 'compression'; import winston from 'winston'; import 'winston-daily-rotate-file'; @@ -29,9 +29,10 @@ let csvPathsCache = null; let lastFetchTime = 0; const CACHE_DURATION = 60 * 1000 * 60 * 24; // 24小时 -const csvCache = new LRU({ +// 使用新的 LRUCache 构造函数 +const csvCache = new LRUCache({ max: 100, // 最多缓存100个CSV文件 - maxAge: 1000 * 60 * 60 * 24 // 缓存24小时 + ttl: 1000 * 60 * 60 * 24 // 缓存24小时 }); // 日志名称格式