1
0
mirror of https://github.com/bitwarden/server synced 2025-12-26 05:03:18 +00:00

[PM-12642] Add new ExtendedCache to add caching to template parameters (#6608)

* Add new ExtendedCache to add caching to template parameters

* Added Cache constants for building consistent keys/name, clarified that we are using defaults including TTL, removed as much fusion cache references as possible
This commit is contained in:
Brant DeBow
2025-11-25 10:58:39 -05:00
committed by GitHub
parent f0f10bcb95
commit 1413dd7689
6 changed files with 353 additions and 108 deletions

View File

@@ -0,0 +1,41 @@
using Bit.Core.Utilities;
using Bit.Test.Common.AutoFixture.Attributes;
using Xunit;
namespace Bit.Core.Test.Utilities;
public class EventIntegrationsCacheConstantsTests
{
[Theory, BitAutoData]
public void BuildCacheKeyForGroup_ReturnsExpectedKey(Guid groupId)
{
var expected = $"Group:{groupId:N}";
var key = EventIntegrationsCacheConstants.BuildCacheKeyForGroup(groupId);
Assert.Equal(expected, key);
}
[Theory, BitAutoData]
public void BuildCacheKeyForOrganization_ReturnsExpectedKey(Guid orgId)
{
var expected = $"Organization:{orgId:N}";
var key = EventIntegrationsCacheConstants.BuildCacheKeyForOrganization(orgId);
Assert.Equal(expected, key);
}
[Theory, BitAutoData]
public void BuildCacheKeyForOrganizationUser_ReturnsExpectedKey(Guid orgId, Guid userId)
{
var expected = $"OrganizationUserUserDetails:{orgId:N}:{userId:N}";
var key = EventIntegrationsCacheConstants.BuildCacheKeyForOrganizationUser(orgId, userId);
Assert.Equal(expected, key);
}
[Fact]
public void CacheName_ReturnsExpected()
{
Assert.Equal("EventIntegrations", EventIntegrationsCacheConstants.CacheName);
}
}