0

我正在尝试使用@pnp-Storage为 SPFX WebPart 实现缓存。缓存在 Temas 浏览器中工作正常,但在 Teams 客户端中,它不起作用。它非常慢,因为我必须进行多个天蓝色函数调用。有人可以帮我在团队的应用程序中缓存吗?请参考下面的代码。

// Getting data from session variable
This.isListsExists = this.storage.session.get(isListsExists);

// If it exists in the session variable then don't make the HTTP call. Otherwise, make the  
// call and save it in the session variable.

if (!this.isListsExists) {
  this.isListsExists = await this.mapDataProvider.checkIfAllListsExist(); //cache 
  // Setting Session variable.
  this.storage.session.put(isListsExists, this.isListsExists, end);
}
4

1 回答 1

0

我使用的是会话存储,它没有与团队合作,但是当我将它更改为本地存储时,它就像一个魅力。

 // Edit - Cache code
this.isListsExists = this.storage.local.get(isListsExistsCache);
// console.log("isListsExists - " + this.isListsExists);
if (!this.isListsExists) {
  this.isListsExists = await this.mapDataProvider.checkIfAllListsExist(); //cache 
  this.storage.local.put(isListsExistsCache, this.isListsExists, end);
}
于 2021-06-30T14:29:21.037 回答