TokenCache class
内存中令牌缓存管理器
属性
| persistence |
方法
| deserialize(string) | 将 JSON 反序列化为内存中缓存。 JSON 应采用 MSAL 缓存架构格式 |
| get |
返回与 homeAccountId 匹配的已登录帐户。 (在成功登录时创建帐户对象),如果未找到匹配的帐户,则为 null |
| get |
返回与 localAccountId 匹配的已登录帐户。 (在成功登录时创建帐户对象),如果未找到匹配的帐户,则为 null |
| get |
用于检索当前缓存中的所有帐户的 API |
| get |
获取 CacheKVStore 格式的缓存快照 |
| get |
提取缓存键值映射 |
| has |
如果自上次序列化或 writeToPersistence 以来缓存状态发生更改,则设置为 true |
| overwrite |
使用永久性缓存覆盖内存中缓存 |
| remove |
用于从缓存中删除特定帐户和相关数据的 API |
| serialize() | 将内存缓存中的序列化为 JSON |
构造函数详细信息
TokenCache(NodeStorage, Logger, ICachePlugin)
new TokenCache(storage: NodeStorage, logger: Logger, cachePlugin?: ICachePlugin)
参数
- storage
-
NodeStorage
- logger
- Logger
- cachePlugin
- ICachePlugin
属性详细信息
persistence
方法详细信息
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()
getKVStore()
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