无论如何要从GetInitialProps内部访问Express Cache?

时间:2019-02-15 02:33:26

标签: next.js

当getInitialProps被称为在服务器端isServer = !!req上运行时,如何获得在运行nextjs应用程序的server.js脚本中创建的缓存?

也就是说,在我的快递服务器中,我创建了这样的缓存:

const LRUCache = require('lru-cache');
const ssrCache = new LRUCache({...});

在我的getInitialProps中,我想以这种方式访问​​我的缓存,但不知道如何将引用传递给ssrCache

Index.getInitialProps = async ({ req }) => {
  const isServer = !!req;
  if (isServer) {
     whatReferenceHere.ssrCache.get('mydatacachename');
     ...

也就是说,我将如何定义whatReferenceHere

0 个答案:

没有答案