
// 運行與服務端的js // node.js lru-cache import LRU from 'lru-cache' const lruCache = LRU({ // 緩存隊列長度 max: 2000, // 緩存有效期 maxAge: 60000 }) export const cache = { get: function (key) { let result = lruCache.get(key) if (result) { return JSON.parse(result) } return null }, set: function (key, value) { if (value) { lruCache.set(key, JSON.stringify(value)) return true } return false } }