Implemented distributed caching
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user