AsyncMemoryStorage class
This class allows MSAL to store artifacts asynchronously using the DatabaseStorage IndexedDB wrapper, backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
Constructors
Async |
Methods
clear |
Clears in-memory Map |
clear |
Tries to delete the IndexedDB database |
contains |
Returns true or false if the given key is present in the cache. |
get |
Get the item matching the given key. Tries in-memory cache first, then in the asynchronous storage object if item isn't found in-memory. |
get |
Get all the keys from the in-memory cache as an iterable array of strings. If no keys are found, query the keys in the asynchronous storage object. |
remove |
Removes the item matching the key from the in-memory cache, then tries to remove it from the asynchronous storage object. |
set |
Sets the item in the in-memory cache and then tries to set it in the asynchronous storage object with the given key. |
Constructor Details
AsyncMemoryStorage(Logger, string)
new AsyncMemoryStorage(logger: Logger, storeName: string)
Parameters
- logger
-
Logger
- storeName
-
string
Method Details
clearInMemory()
Clears in-memory Map
function clearInMemory()
clearPersistent()
Tries to delete the IndexedDB database
function clearPersistent(): Promise<boolean>
Returns
Promise<boolean>
containsKey(string)
Returns true or false if the given key is present in the cache.
function containsKey(key: string): Promise<boolean>
Parameters
- key
-
string
Returns
Promise<boolean>
getItem(string)
Get the item matching the given key. Tries in-memory cache first, then in the asynchronous storage object if item isn't found in-memory.
function getItem(key: string): Promise<T | null>
Parameters
- key
-
string
Returns
Promise<T | null>
getKeys()
Get all the keys from the in-memory cache as an iterable array of strings. If no keys are found, query the keys in the asynchronous storage object.
function getKeys(): Promise<string[]>
Returns
Promise<string[]>
removeItem(string)
Removes the item matching the key from the in-memory cache, then tries to remove it from the asynchronous storage object.
function removeItem(key: string): Promise<void>
Parameters
- key
-
string
Returns
Promise<void>
setItem(string, T)
Sets the item in the in-memory cache and then tries to set it in the asynchronous storage object with the given key.
function setItem(key: string, value: T): Promise<void>
Parameters
- key
-
string
- value
-
T
Returns
Promise<void>