nextjs应用memory-cache插件实现服务端缓存
import cacheData from 'memory-cache';async function putCache(url, options) { // url为缓存标识 const value = cacheData.get(url); // 获取缓存 if (value) { // 如果有缓存 *codeing* } else { const hours = 24; // 申请接口 获取data cacheData.put(url, data, hours * 1000 * 60 * 60); // url 为缓存标识 data为数据 第三参数为以毫秒为单位的工夫 return data; }}