mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:43:26 +08:00
【优化】移除EasyCaching.Core,EasyCaching.CSRedis,EasyCaching.InMemory等组件,直接使用原生CSRedis组件,替换SqlSugar二级缓存组件。
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.AutoMate.RedisCache;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CSRedis;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StackExchange.Redis;
|
||||
|
||||
@@ -19,6 +20,13 @@ namespace CoreCms.Net.Core.Config
|
||||
{
|
||||
if (services == null) throw new ArgumentNullException(nameof(services));
|
||||
|
||||
|
||||
if (AppSettingsConstVars.RedisUseCache)
|
||||
{
|
||||
//初始化Redis及分布式缓存
|
||||
RedisHelper.Initialization(new CSRedisClient(AppSettingsConstVars.RedisConfigConnectionString));
|
||||
}
|
||||
|
||||
services.AddTransient<IRedisOperationRepository, RedisOperationRepository>();
|
||||
|
||||
// 配置启动Redis服务,虽然可能影响项目启动速度,但是不能在运行的时候报错,所以是合理的
|
||||
@@ -34,6 +42,7 @@ namespace CoreCms.Net.Core.Config
|
||||
return ConnectionMultiplexer.Connect(configuration);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,7 @@ namespace CoreCms.Net.Core.Config
|
||||
db.CurrentConnectionConfig.ConfigureExternalServices = new ConfigureExternalServices()
|
||||
{
|
||||
//判断是否开启redis设置二级缓存方式
|
||||
//DataInfoCacheService = AppSettingsConstVars.RedisUseCache ? (ICacheService)new SqlSugarRedisCache() : new SqlSugarMemoryCache()
|
||||
DataInfoCacheService = new SqlSugarCache()
|
||||
DataInfoCacheService = AppSettingsConstVars.RedisUseCache ? new SqlSugarRedisCache() : new SqlSugarMemoryCache()
|
||||
};
|
||||
db.CurrentConnectionConfig.MoreSettings = new ConnMoreSettings()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user