1
0
mirror of https://github.com/bitwarden/server synced 2026-01-02 08:33:48 +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,52 @@
using Bit.Core.AdminConsole.Entities;
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
namespace Bit.Core.Utilities;
/// <summary>
/// Provides cache key generation helpers and cache name constants for event integrationrelated entities.
/// </summary>
public static class EventIntegrationsCacheConstants
{
/// <summary>
/// The base cache name used for storing event integration data.
/// </summary>
public static readonly string CacheName = "EventIntegrations";
/// <summary>
/// Builds a deterministic cache key for a <see cref="Group"/>.
/// </summary>
/// <param name="groupId">The unique identifier of the group.</param>
/// <returns>
/// A cache key for this Group.
/// </returns>
public static string BuildCacheKeyForGroup(Guid groupId)
{
return $"Group:{groupId:N}";
}
/// <summary>
/// Builds a deterministic cache key for an <see cref="Organization"/>.
/// </summary>
/// <param name="organizationId">The unique identifier of the organization.</param>
/// <returns>
/// A cache key for the Organization.
/// </returns>
public static string BuildCacheKeyForOrganization(Guid organizationId)
{
return $"Organization:{organizationId:N}";
}
/// <summary>
/// Builds a deterministic cache key for an organization user <see cref="OrganizationUserUserDetails"/>.
/// </summary>
/// <param name="organizationId">The unique identifier of the organization to which the user belongs.</param>
/// <param name="userId">The unique identifier of the user.</param>
/// <returns>
/// A cache key for the user.
/// </returns>
public static string BuildCacheKeyForOrganizationUser(Guid organizationId, Guid userId)
{
return $"OrganizationUserUserDetails:{organizationId:N}:{userId:N}";
}
}