1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 08:32:50 -05:00

Use FrozenDictionary in StaticClientStore (#3833)

* Add Benchmark

* Use FrozenDictionary

* Use TryGetValue

* Format
This commit is contained in:
Justin Baur
2024-02-21 10:29:59 -05:00
committed by GitHub
parent 0abd52b5be
commit 70fac808b0
3 changed files with 33 additions and 5 deletions

View File

@ -80,9 +80,9 @@ public class ClientStore : IClientStore
return await CreateUserClientAsync(clientId);
}
if (_staticClientStore.ApiClients.ContainsKey(clientId))
if (_staticClientStore.ApiClients.TryGetValue(clientId, out var client))
{
return _staticClientStore.ApiClients[clientId];
return client;
}
return await CreateApiKeyClientAsync(clientId);

View File

@ -1,4 +1,5 @@
using Bit.Core.Enums;
using System.Collections.Frozen;
using Bit.Core.Enums;
using Bit.Core.Settings;
using Duende.IdentityServer.Models;
@ -16,8 +17,8 @@ public class StaticClientStore
new ApiClient(globalSettings, BitwardenClient.Desktop, 30, 1),
new ApiClient(globalSettings, BitwardenClient.Cli, 30, 1),
new ApiClient(globalSettings, BitwardenClient.DirectoryConnector, 30, 24)
}.ToDictionary(c => c.ClientId);
}.ToFrozenDictionary(c => c.ClientId);
}
public IDictionary<string, Client> ApiClients { get; private set; }
public FrozenDictionary<string, Client> ApiClients { get; }
}