mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
33 lines
1.1 KiB
using System;
|
|
using Microsoft.Extensions.Caching.Distributed;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using Volo.Abp.Modularity;
|
|
|
|
namespace Volo.Abp.Caching.StackExchangeRedis;
|
|
|
|
[DependsOn(
|
|
typeof(AbpCachingModule)
|
|
)]
|
|
public class AbpCachingStackExchangeRedisModule : AbpModule
|
|
{
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
var redisEnabled = configuration["Redis:IsEnabled"];
|
|
if (string.IsNullOrEmpty(redisEnabled) || bool.Parse(redisEnabled))
|
|
{
|
|
context.Services.AddStackExchangeRedisCache(options =>
|
|
{
|
|
var redisConfiguration = configuration["Redis:Configuration"];
|
|
if (!redisConfiguration.IsNullOrEmpty())
|
|
{
|
|
options.Configuration = redisConfiguration;
|
|
}
|
|
});
|
|
|
|
context.Services.Replace(ServiceDescriptor.Singleton<IDistributedCache, AbpRedisCache>());
|
|
}
|
|
}
|
|
}
|
|
|