Implemented distributed caching

This commit is contained in:
2026-09-03 11:09:05 +02:00
parent d55fb59d8d
commit da4499ce41
6 changed files with 40 additions and 6 deletions
@@ -1,11 +1,12 @@
using PostFundManagement.Application.Abstractions;
using Microsoft.Extensions.Caching.Hybrid;
using PostFundManagement.Application.Abstractions;
using PostFundManagement.Domain.Abstractions;
namespace PostFundManagement.Application.Extensions;
public static class General
{
public static IServiceCollection AddRegisterServices(this IServiceCollection services)
public static IServiceCollection AddRegisterServices(this IServiceCollection services, IConfiguration configuration)
{
var serviceType = typeof(IService);
@@ -14,6 +15,15 @@ public static class General
foreach (var sharedImplementation in sharedImplementations) services.AddScoped(sharedImplementation);
services.AddStackExchangeRedisCache(options =>
options.Configuration = configuration.GetConnectionString("Redis"));
services.AddHybridCache(options => options.DefaultEntryOptions = new HybridCacheEntryOptions
{
Expiration = TimeSpan.FromMinutes(2),
LocalCacheExpiration = TimeSpan.FromMinutes(1)
});
return services;
}