本機 儲存體 API
使用本機記憶體 API,您可以將資料儲存在瀏覽器的本機記憶體中。 若要使用本機記憶體 API,必須啟用客戶的本機 記憶體管理員參數 。
本機記憶體會隔離,讓每種視覺效果類型都有自己的個別記憶體存取權。
注意
開發人員有責任確保儲存的數據符合取用者的組織原則,並在數據需要敏感度時通知用戶儲存哪些資訊。 特別是,如果商務目標或案例預期數據,自定義視覺效果開發人員應該加密數據。
如何使用本機記憶體
此版本的 本機記憶體 API 已排程淘汰。 我們不會再接受任何要求。 可能的話,請使用第 2 版。
在下列範例中,每當 呼叫 update 方法時,就會增加計數器。 計數器值會在本機儲存,並在每次視覺效果啟動時呼叫。 如此一來,計數器就會繼續從離開的位置進行計數,而不是在每次啟動視覺效果時開始:
export class Visual implements IVisual {
// ...
private updateCountName: string = 'updateCount';
private updateCount: number;
private storage: ILocalVisualStorageService;
// ...
constructor(options: VisualConstructorOptions) {
// ...
this.storage = options.host.storageService;
// ...
this.storage.get(this.updateCountName).then(count =>
{
this.updateCount = +count;
})
.catch(() =>
{
this.updateCount = 0;
this.storage.set(this.updateCountName, this.updateCount.toString());
});
// ...
}
public update(options: VisualUpdateOptions) {
// ...
this.updateCount++;
this.storage.set(this.updateCountName, this.updateCount.toString());
// ...
}
}
考量與限制
- 本機記憶體限制是每個 GUID 1 MB。
- 只有相同的 GUID 才能在視覺效果之間共享數據。
- 數據無法與 Power BI Desktop 的另一個實例共用。
- 預設不會啟用本機記憶體 API。 若要開啟 Power BI 視覺效果的要求,請將要求傳送給 Power BI 視覺效果支援 。
pbicvsupport@microsoft.com
- 本機記憶體 API 不支援
await
建構。 只then
允許和catch
方法。
相關內容
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應