public void SaveAccessToken(MsalAccessTokenCacheItem item)
        {
            string itemKey      = item.GetKey().ToString();
            string partitionKey = CacheKeyFactory.GetClientCredentialKey(item.ClientId, item.TenantId, item.KeyId);

            // if a conflict occurs, pick the latest value
            AccessTokenCacheDictionary
            .GetOrAdd(partitionKey, new ConcurrentDictionary <string, MsalAccessTokenCacheItem>())[itemKey] = item;
        }
        public void DeleteAccessToken(MsalAccessTokenCacheItem item)
        {
            var partitionKey = CacheKeyFactory.GetClientCredentialKey(item.ClientId, item.TenantId, item.KeyId);

            AccessTokenCacheDictionary.TryGetValue(partitionKey, out var partition);
            if (partition == null || !partition.TryRemove(item.GetKey().ToString(), out _))
            {
                _logger.InfoPii(
                    $"Cannot delete access token because it was not found in the cache. Key {item.GetKey()}.",
                    "Cannot delete access token because it was not found in the cache.");
            }
        }
 private string GetPartitionKey(bool isAppCache, MsalAccessTokenCacheItem atItem)
 {
     return(isAppCache ?
            CacheKeyFactory.GetClientCredentialKey(atItem.ClientId, atItem.TenantId, atItem.KeyId) :
            CacheKeyFactory.GetKeyFromCachedItem(atItem));
 }