Skip to content

Commit 7587d1a

Browse files
committed
removing fusionCache and updating DistributedCache
1 parent 803e235 commit 7587d1a

File tree

6 files changed

+64
-79
lines changed

6 files changed

+64
-79
lines changed

Readme.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ builder
138138
.AddMediatrWithBehaviors(AssemblyRegistry.ToArray())
139139
.AddResilienceDefaultPipeline()
140140
.MapDefaultTimeZone()
141-
.AddDistributedFusionCache("redis://localhost:6379",
142-
builder.Environment.GetShortEnvironmentName() + "_" + "app_name") // or .AddFusionCache(...)
141+
.AddDistributedCache(o =>
142+
{
143+
o.RedisConnectionString = "redis://localhost:6379";
144+
o.ChannelPrefix = "app_name:";
145+
})
143146
.AddDistributedSignalR("redis://localhost:6379","app_name:") // or .AddSignalR()
144147
.AddCors()
145148
.AddHealthChecks();
@@ -622,14 +625,14 @@ This package includes various extensions and utilities to aid development:
622625
retrieves DefaultTimeZone from `appsettings.json` and sets it as the default time zone.
623626
- **UrlBuilder:** A utility for building URLs with query parameters.
624627
- **Language ISO Code Helper:** Validate, query, and retrieve information about ISO language codes.
625-
- **FusionCache Extensions:** Simplify the configuration of in memory or distributed caching with Redis.
626628

627629
### Related NuGet Packages
628630

629631
- **Pandatech.Crypto:** Provides cryptographic utilities.
630632
- **Pandatech.FluentMinimalApiMapper:** Simplifies mapping in minimal APIs.
631633
- **Pandatech.RegexBox:** A collection of useful regular expressions.
632634
- **Pandatech.ResponseCrafter:** A utility for crafting consistent API responses.
635+
- **Pandatech.DistributedCache:** A distributed cache provider for Redis.
633636

634637
## License
635638

Shared.Kernel.Demo/Program.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using DistributedCache.Extensions;
12
using DistributedCache.Options;
23
using FluentMinimalApiMapper;
34
using Microsoft.AspNetCore.Mvc;
@@ -26,9 +27,12 @@
2627
.AddControllers(AssemblyRegistry.ToArray())
2728
.AddMediatrWithBehaviors(AssemblyRegistry.ToArray())
2829
.AddResilienceDefaultPipeline()
29-
.AddDistributedFusionCache("redis://localhost:6379",
30-
builder.Environment.GetShortEnvironmentName() + "_" + "app_name") // or .AddFusionCache(...)
31-
.AddDistributedSignalR("redis://localhost:6379","app_name:") // or .AddSignalR()
30+
.AddDistributedSignalR("redis://localhost:6379", "app_name:") // or .AddSignalR()
31+
.AddDistributedCache(o =>
32+
{
33+
o.RedisConnectionString = "redis://localhost:6379";
34+
o.ChannelPrefix = "app_name:";
35+
})
3236
.MapDefaultTimeZone()
3337
.AddCors()
3438
.AddOutboundLoggingHandler()

src/SharedKernel/Extensions/DistributedCacheExtension.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
using Microsoft.AspNetCore.Builder;
2-
using Microsoft.Extensions.Caching.StackExchangeRedis;
3-
using Microsoft.Extensions.DependencyInjection;
4-
using ZiggyCreatures.Caching.Fusion;
5-
6-
namespace SharedKernel.Extensions;
7-
8-
public static class FusionCacheExtensions
9-
{
10-
private static IFusionCacheBuilder AddBaseFusionCache(WebApplicationBuilder builder, string instanceName)
11-
{
12-
return builder.Services
13-
.AddFusionCache()
14-
.WithRegisteredLogger()
15-
.WithNeueccMessagePackSerializer()
16-
.WithDefaultEntryOptions(new FusionCacheEntryOptions())
17-
.WithCacheKeyPrefix(instanceName);
18-
}
19-
20-
21-
public static WebApplicationBuilder AddDistributedFusionCache(this WebApplicationBuilder builder,
22-
string redisUrl,
23-
string instanceName)
24-
{
25-
AddBaseFusionCache(builder, instanceName)
26-
.WithDistributedCache(new RedisCache(new RedisCacheOptions
27-
{
28-
Configuration = redisUrl,
29-
InstanceName = instanceName
30-
}))
31-
.WithStackExchangeRedisBackplane(o => o.Configuration = redisUrl)
32-
.AsHybridCache();
33-
34-
return builder;
35-
}
36-
37-
public static WebApplicationBuilder AddFusionCache(this WebApplicationBuilder builder, string instanceName)
38-
{
39-
AddBaseFusionCache(builder, instanceName);
40-
return builder;
41-
}
42-
}
1+
// using Microsoft.AspNetCore.Builder;
2+
// using Microsoft.Extensions.Caching.StackExchangeRedis;
3+
// using Microsoft.Extensions.DependencyInjection;
4+
// using ZiggyCreatures.Caching.Fusion;
5+
//
6+
// namespace SharedKernel.Extensions;
7+
//
8+
// public static class FusionCacheExtensions
9+
// {
10+
// private static IFusionCacheBuilder AddBaseFusionCache(WebApplicationBuilder builder, string instanceName)
11+
// {
12+
// return builder.Services
13+
// .AddFusionCache()
14+
// .WithRegisteredLogger()
15+
// .WithNeueccMessagePackSerializer()
16+
// .WithDefaultEntryOptions(new FusionCacheEntryOptions())
17+
// .WithCacheKeyPrefix(instanceName)
18+
// .AsHybridCache();
19+
// }
20+
//
21+
//
22+
// public static WebApplicationBuilder AddDistributedFusionCache(this WebApplicationBuilder builder,
23+
// string redisUrl,
24+
// string instanceName)
25+
// {
26+
// AddBaseFusionCache(builder, instanceName)
27+
// .WithDistributedCache(new RedisCache(new RedisCacheOptions
28+
// {
29+
// Configuration = redisUrl,
30+
// InstanceName = instanceName
31+
// }))
32+
// .WithStackExchangeRedisBackplane(o => o.Configuration = redisUrl);
33+
//
34+
// return builder;
35+
// }
36+
//
37+
// public static WebApplicationBuilder AddFusionCache(this WebApplicationBuilder builder, string instanceName)
38+
// {
39+
// AddBaseFusionCache(builder, instanceName);
40+
// return builder;
41+
// }
42+
// }

src/SharedKernel/Extensions/OpenTelemetryExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public static WebApplicationBuilder AddOpenTelemetry(this WebApplicationBuilder
2727
.WithMetrics(metrics =>
2828
{
2929
metrics.AddRuntimeInstrumentation()
30-
.AddFusionCacheInstrumentation()
30+
// .AddFusionCacheInstrumentation()
3131
.AddAspNetCoreInstrumentation()
3232
.AddHttpClientInstrumentation()
3333
.AddPrometheusExporter();
3434
})
3535
.WithTracing(tracing =>
3636
{
3737
tracing
38-
.AddFusionCacheInstrumentation()
38+
// .AddFusionCacheInstrumentation()
3939
.AddAspNetCoreInstrumentation()
4040
.AddHttpClientInstrumentation()
4141
.AddEntityFrameworkCoreInstrumentation();

src/SharedKernel/SharedKernel.csproj

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<PackageReadmeFile>Readme.md</PackageReadmeFile>
99
<Authors>Pandatech</Authors>
1010
<Copyright>MIT</Copyright>
11-
<Version>1.2.0</Version>
11+
<Version>1.2.1</Version>
1212
<PackageId>Pandatech.SharedKernel</PackageId>
1313
<Title>Pandatech Shared Kernel Library</Title>
1414
<PackageTags>Pandatech, shared kernel, library, OpenAPI, Swagger, utilities, scalar</PackageTags>
1515
<Description>Pandatech.SharedKernel provides centralized configurations, utilities, and extensions for ASP.NET Core projects. For more information refere to readme.md document.</Description>
1616
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-sharedkernel</RepositoryUrl>
17-
<PackageReleaseNotes>Added fusion cache support</PackageReleaseNotes>
17+
<PackageReleaseNotes>Updated nuget packages</PackageReleaseNotes>
1818
</PropertyGroup>
1919

2020
<ItemGroup>
@@ -43,22 +43,19 @@
4343
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.11.1" />
4444
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.8.0-rc.1"/>
4545
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.11.1" />
46-
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.10.1" />
46+
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.11.0" />
4747
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.12" />
48-
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.10.0" />
49-
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.10.0" />
48+
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.11.0" />
49+
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.11.0" />
5050
<PackageReference Include="Pandatech.Crypto" Version="4.1.1" />
51-
<PackageReference Include="Pandatech.DistributedCache" Version="3.0.1" />
51+
<PackageReference Include="Pandatech.DistributedCache" Version="4.0.0" />
5252
<PackageReference Include="Pandatech.FluentMinimalApiMapper" Version="2.0.1" />
5353
<PackageReference Include="Pandatech.PandaVaultClient" Version="4.0.3" />
5454
<PackageReference Include="Pandatech.RegexBox" Version="3.0.0" />
5555
<PackageReference Include="Pandatech.ResponseCrafter" Version="5.1.5" />
56-
<PackageReference Include="Scalar.AspNetCore" Version="2.0.4" />
56+
<PackageReference Include="Scalar.AspNetCore" Version="2.0.5" />
5757
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
5858
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.2.0" />
59-
<PackageReference Include="ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis" Version="2.0.0" />
60-
<PackageReference Include="ZiggyCreatures.FusionCache.OpenTelemetry" Version="2.0.0" />
61-
<PackageReference Include="ZiggyCreatures.FusionCache.Serialization.NeueccMessagePack" Version="2.0.0" />
6259
</ItemGroup>
6360

6461
</Project>

0 commit comments

Comments
 (0)