为Express JS应用程序创建一个缓存系统与API连接

时间:2018-01-28 14:16:37

标签: node.js api express caching

[等级英语=非常糟糕(来自法国......)]

我有一个带有node.js和epress.js的简单应用程序

此应用使用de模块“igdb-api-node”连接igdb api(https://www.igdb.com/api

我使用此代码获取游戏whith关键字:

exports.findGameByKeyWord = function(req, res) {
  return client.games({
      fields: '*',
      limit: 20,
      offset: 0,
      search: req.params.text
  }).then(igdbResponse => {
    res.send(igdbResponse.body);
  });
};

所有这些工作都很棒,但现在我想将请求的结果存储在缓存中。

我想制作这个以加快结果的返回。

我一直在观看不同的想法,但这对我来说有点复杂,我想要一个例子来理解。

这里,我探索过的曲目:

https://github.com/BryanDonovan/node-cache-manager

https://www.npmjs.com/package/route-cache

https://github.com/kwhitley/apicache

https://github.com/evanshortiss/express-expeditious

https://github.com/dantman/express-cache-response-directive

0 个答案:

没有答案