TokenCache class

内存中令牌缓存管理器

属性

persistence

方法

deserialize(string)

将 JSON 反序列化为内存中缓存。 JSON 应采用 MSAL 缓存架构格式

getAccountByHomeId(string)

返回与 homeAccountId 匹配的已登录帐户。 (在成功登录时创建帐户对象),如果未找到匹配的帐户,则为 null

getAccountByLocalId(string)

返回与 localAccountId 匹配的已登录帐户。 (在成功登录时创建帐户对象),如果未找到匹配的帐户,则为 null

getAllAccounts(string)

用于检索当前缓存中的所有帐户的 API

getCacheSnapshot()

获取 CacheKVStore 格式的缓存快照

getKVStore()

提取缓存键值映射

hasChanged()

如果自上次序列化或 writeToPersistence 以来缓存状态发生更改,则设置为 true

overwriteCache()

使用永久性缓存覆盖内存中缓存

removeAccount(AccountInfo, string)

用于从缓存中删除特定帐户和相关数据的 API

serialize()

将内存缓存中的序列化为 JSON

构造函数详细信息

TokenCache(NodeStorage, Logger, ICachePlugin)

new TokenCache(storage: NodeStorage, logger: Logger, cachePlugin?: ICachePlugin)

参数

storage

NodeStorage

logger
Logger
cachePlugin
ICachePlugin

属性详细信息

persistence

persistence: ICachePlugin

属性值

方法详细信息

deserialize(string)

将 JSON 反序列化为内存中缓存。 JSON 应采用 MSAL 缓存架构格式

function deserialize(cache: string)

参数

cache

string

blob 格式化缓存

getAccountByHomeId(string)

返回与 homeAccountId 匹配的已登录帐户。 (在成功登录时创建帐户对象),如果未找到匹配的帐户,则为 null

function getAccountByHomeId(homeAccountId: string): Promise<null | AccountInfo>

参数

homeAccountId

string

帐户的唯一标识符(uid.utid)

返回

Promise<null | AccountInfo>

getAccountByLocalId(string)

返回与 localAccountId 匹配的已登录帐户。 (在成功登录时创建帐户对象),如果未找到匹配的帐户,则为 null

function getAccountByLocalId(localAccountId: string): Promise<null | AccountInfo>

参数

localAccountId

string

帐户的唯一标识符(无法填充 homeAccountId 时 sub/obj)

返回

Promise<null | AccountInfo>

getAllAccounts(string)

用于检索当前缓存中的所有帐户的 API

function getAllAccounts(correlationId?: string): Promise<AccountInfo[]>

参数

correlationId

string

返回

Promise<AccountInfo[]>

getCacheSnapshot()

获取 CacheKVStore 格式的缓存快照

function getCacheSnapshot(): CacheKVStore

返回

getKVStore()

提取缓存键值映射

function getKVStore(): CacheKVStore

返回

hasChanged()

如果自上次序列化或 writeToPersistence 以来缓存状态发生更改,则设置为 true

function hasChanged(): boolean

返回

boolean

overwriteCache()

使用永久性缓存覆盖内存中缓存

function overwriteCache(): Promise<void>

返回

Promise<void>

removeAccount(AccountInfo, string)

用于从缓存中删除特定帐户和相关数据的 API

function removeAccount(account: AccountInfo, correlationId?: string): Promise<void>

参数

account
AccountInfo

用户传递的 AccountInfo

correlationId

string

返回

Promise<void>

serialize()

将内存缓存中的序列化为 JSON

function serialize(): string

返回

string