Skip to content

Commit 21a7ab3

Browse files
authored
feat(templates): use auto-clone feature of the fusion cache to prevent further scale out issues when swtiching to redis #11759 (#11760)
1 parent 4874691 commit 21a7ab3

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

src/Templates/Boilerplate/Bit.Boilerplate/.github/copilot-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ The solution is organized into the following projects. Understand their roles to
6060

6161
- **DeepWiki**: Provides access to an extensive knowledge base for the `bitfoundation/bitplatform` and `riok/mapperly` repositories.
6262
- **Website Fetcher**: Gathers information from URLs provided by the user, using `fetch` or `get_web_pages` tools.
63+
- **Microsoft Learn**: Provides access to official Microsoft documentation and code samples for Azure, .NET Aspire, .NET MAUI, Entity Framework Core, SignalR, Microsoft.Extensions.AI, SQL Server, and other Microsoft technologies. Use `microsoft_docs_search` to find relevant documentation and `microsoft_code_sample_search` to find official code examples.
6364

6465
## 5. Mandatory Workflow
6566

src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,6 @@
134134
<PackageVersion Include="Microsoft.Playwright.MSTest.v4" Version="1.56.0" />
135135
<PackageVersion Include="ZiggyCreatures.FusionCache.AspNetCore.OutputCaching" Version="2.4.0" />
136136
<PackageVersion Include="ZiggyCreatures.FusionCache.OpenTelemetry" Version="2.4.0" />
137+
<PackageVersion Include="ZiggyCreatures.FusionCache.Serialization.SystemTextJson" Version="2.4.0" />
137138
</ItemGroup>
138139
</Project>

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Boilerplate.Server.Shared.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
<PackageReference Include="OpenTelemetry.Resources.OperatingSystem" />
3030
<PackageReference Include="OpenTelemetry.Resources.Process" />
3131
<PackageReference Include="OpenTelemetry.Resources.ProcessRuntime" />
32-
<PackageReference Include="ZiggyCreatures.FusionCache.AspNetCore.OutputCaching" />
3332
<PackageReference Include="ZiggyCreatures.FusionCache.OpenTelemetry" />
33+
<PackageReference Include="ZiggyCreatures.FusionCache.AspNetCore.OutputCaching" />
34+
<PackageReference Include="ZiggyCreatures.FusionCache.Serialization.SystemTextJson" />
3435
</ItemGroup>
3536

3637
<ItemGroup>

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationBuilderExtensions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
using OpenTelemetry.Metrics;
1515
using OpenTelemetry.Resources;
1616
using OpenTelemetry.Trace;
17+
using ZiggyCreatures.Caching.Fusion;
18+
using ZiggyCreatures.Caching.Fusion.Serialization.SystemTextJson;
1719

1820
namespace Microsoft.Extensions.Hosting;
1921

@@ -44,7 +46,10 @@ public static TBuilder AddServerSharedServices<TBuilder>(this TBuilder builder)
4446
}, excludeDefaultPolicy: true);
4547
});
4648

47-
services.AddFusionCache();
49+
services.AddFusionCache()
50+
// Auto-clone cached objects to avoid further issues after scaling out and switching to distributed caching.
51+
.WithOptions(opt => opt.DefaultEntryOptions.EnableAutoClone = true)
52+
.WithSerializer(new FusionCacheSystemTextJsonSerializer());
4853
services.AddFusionOutputCache(); // For ASP.NET Core Output Caching with FusionCache
4954

5055
services.AddHttpContextAccessor();

src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Exceptions/KnownException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
namespace Boilerplate.Shared.Exceptions;
1+
namespace Boilerplate.Shared.Exceptions;
22

3-
public abstract partial class KnownException : Exception
3+
public abstract partial class KnownException : ApplicationException
44
{
55
public KnownException(string message)
66
: base(message)

0 commit comments

Comments
 (0)