mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 20:13:26 +08:00
【新增】新增【EasyCaching.CSRedis】redis组件,替换SqlSugar二级缓存的【StackExchange.Redis】组件实现,使用异步替代同步处理二级缓存,解决【StackExchange.Redis】超过200并发后的异常情况。异步提升二级缓存获取效率。
【新增】appsetting.json配置文件增加【AppPcUrl】PC端访问地址,【AppH5Url】H5端访问地址,方便对接pc端、h5端、微信公众号端。
This commit is contained in:
@@ -48,6 +48,9 @@
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.1" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
|
||||
<PackageReference Include="EasyCaching.CSRedis" Version="1.7.0" />
|
||||
<PackageReference Include="EasyCaching.InMemory" Version="1.7.0" />
|
||||
<PackageReference Include="EasyCaching.Serialization.Json" Version="1.7.0" />
|
||||
<PackageReference Include="Essensoft.Paylink.Alipay" Version="4.0.14" />
|
||||
<PackageReference Include="Essensoft.Paylink.WeChatPay" Version="4.0.14" />
|
||||
<PackageReference Include="IdentityModel" Version="6.0.0" />
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
dbProvider="Microsoft.Data.SqlClient.SqlConnection, Microsoft.Data.SqlClient"
|
||||
connectionString="Server=127.0.0.1;Database=BaseMIS;User ID=sa;Password=123456"
|
||||
-->
|
||||
<target name="log_database" xsi:type="Database" dbProvider="MySql.Data.MySqlClient.MySqlConnection,Mysql.Data" connectionString="Server=rm-wz92918pm46bsbc37mo.mysql.rds.aliyuncs.com;Port=3306;Database=coreshop;Uid=coreshop;Pwd=coreshop;CharSet=utf8;pooling=true;SslMode=None;Allow User Variables=true;Convert Zero Datetime=True;Allow Zero Datetime=True;">
|
||||
<target name="log_database" xsi:type="Database" dbProvider="Microsoft.Data.SqlClient.SqlConnection, Microsoft.Data.SqlClient" connectionString="Server=127.0.0.1;uid=CoreShopProfessional;pwd=CoreShopProfessional;Database=CoreShopProfessional;MultipleActiveResultSets=true;pooling=true;min pool size=5;max pool size=32767;connect timeout=20;Encrypt=True;TrustServerCertificate=True;">
|
||||
<commandText>
|
||||
INSERT INTO SysNLogRecords
|
||||
(LogDate,LogLevel,LogType,LogTitle,Logger,Message,MachineName,MachineIp,NetRequestMethod
|
||||
|
||||
@@ -26,6 +26,8 @@ using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.Mapping;
|
||||
using CoreCms.Net.Middlewares;
|
||||
using CoreCms.Net.Swagger;
|
||||
using CoreCms.Net.Utility;
|
||||
using EasyCaching.Core;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
@@ -131,7 +133,25 @@ YitIdHelper.SetIdGenerator(options);
|
||||
//var newId = YitIdHelper.NextId();
|
||||
|
||||
|
||||
#region 缓存配置
|
||||
string cacheProviderName = "default";
|
||||
builder.Services.AddEasyCaching(options =>
|
||||
{
|
||||
////使用文档 https://easycaching.readthedocs.io/en/latest
|
||||
if (AppSettingsConstVars.RedisUseCache)
|
||||
{
|
||||
options.UseCSRedis(builder.Configuration);
|
||||
cacheProviderName = EasyCachingConstValue.DefaultCSRedisName;
|
||||
}
|
||||
else
|
||||
{
|
||||
cacheProviderName = EasyCachingConstValue.DefaultInMemoryName;
|
||||
options.UseInMemory(builder.Configuration);
|
||||
}
|
||||
options.WithJson(cacheProviderName);
|
||||
|
||||
});
|
||||
#endregion
|
||||
|
||||
#region AutoFac注册============================================================================
|
||||
|
||||
@@ -179,6 +199,8 @@ app.UseRequestResponseLog();
|
||||
app.UseRecordAccessLogsMildd(GlobalEnumVars.CoreShopSystemCategory.Admin.ToString());
|
||||
// 记录ip请求 (注意开启权限,不然本地无法写入)
|
||||
app.UseIpLogMildd();
|
||||
//注册csredis中间件处理
|
||||
Storage.Container = app.Services.CreateScope().ServiceProvider.GetAutofacRoot();
|
||||
#endregion
|
||||
|
||||
app.UseSwagger().UseSwaggerUI(c =>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
},
|
||||
"AppConfig": {
|
||||
"AppUrl": "https://admin.test.pro.coreshop.cn/", //后端管理地址
|
||||
"AppPcUrl": "https://pc.test.pro.coreshop.cn/", //PC端访问地址
|
||||
"AppH5Url": "https://h5.test.pro.coreshop.cn/", //H5端访问地址
|
||||
"AppInterFaceUrl": "https://api.test.pro.coreshop.cn/", //接口请求地址
|
||||
"AppVersion": "CoreShopProfessional v0.6.7"
|
||||
},
|
||||
@@ -23,7 +25,38 @@
|
||||
"UseCache": true, //启用redis作为内存选择
|
||||
"UseTimedTask": true, //启用redis作为定时任务
|
||||
// 如果采用容器化部署Service 要写成redis的服务名,否则写地址
|
||||
"ConnectionString": "127.0.0.1:6379,password=coreshop,connectTimeout=30000,responseTimeout=30000,abortConnect=false,connectRetry=1,syncTimeout=10000,DefaultDatabase=9" //redis数据库连接字符串
|
||||
"ConnectionString": "127.0.0.1:6379,password=,connectTimeout=30000,responseTimeout=30000,abortConnect=false,connectRetry=1,syncTimeout=10000,DefaultDatabase=9" //redis数据库连接字符串
|
||||
},
|
||||
"easycaching": {
|
||||
"csredis": {
|
||||
"MaxRdSecond": 0, //预防缓存在同一时间全部失效,可以为每个key的过期时间添加一个随机的秒数,默认值是120秒
|
||||
"EnableLogging": false, // 是否开启日志,默认值是false
|
||||
"LockMs": 5000, // 互斥锁的存活时间, 默认值是5000毫秒
|
||||
"SleepMs": 300, // 没有获取到互斥锁时的休眠时间,默认值是300毫秒
|
||||
"dbconfig": {
|
||||
"ConnectionStrings": [
|
||||
"127.0.0.1:6379,password=,connectTimeout=30000,responseTimeout=30000,abortConnect=false,connectRetry=1,syncTimeout=10000,DefaultDatabase=9" //如果没有密码请保持为空
|
||||
],
|
||||
//"Sentinels": [
|
||||
// "192.169.1.10:26379",
|
||||
// "192.169.1.11:26379",
|
||||
// "192.169.1.12:26379"
|
||||
//],
|
||||
"ReadOnly": false
|
||||
}
|
||||
},
|
||||
"inmemory": {
|
||||
"MaxRdSecond": 0,
|
||||
"EnableLogging": false,
|
||||
"LockMs": 5000,
|
||||
"SleepMs": 300,
|
||||
"DBConfig": {
|
||||
"SizeLimit": 10000,
|
||||
"ExpirationScanFrequency": 60, // InMemory的过期扫描频率,默认值是60秒
|
||||
"EnableReadDeepClone": true,
|
||||
"EnableWriteDeepClone": false
|
||||
}
|
||||
}
|
||||
},
|
||||
//jwt授权认证的一些设置
|
||||
"JwtConfig": {
|
||||
|
||||
Reference in New Issue
Block a user