如何在MS Teams Client SPFX Web部件中实现缓存



我正在尝试使用@pnpStorage为SPFX WebPart实现缓存。缓存在Temas浏览器中运行良好,但在Teams客户端中不起作用。它非常慢,因为我必须进行多个azure函数调用。有人能帮我在团队的应用程序中缓存吗。请参阅下面的代码。

// 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);
}

我使用的是会话存储,它不适用于团队,但当我将其更改为本地存储时,它就像一个魅力。

// 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);
}

最新更新