redis启用新增配置

This commit is contained in:
不做码农 2023-03-08 13:02:38 +08:00
parent a0f4afbe25
commit d13d7666ab
2 changed files with 9 additions and 7 deletions

View File

@ -8,6 +8,7 @@ using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Admin.WebApi.Middleware;
using ZR.Admin.WebApi.Hubs;
using ZR.Common.Cache;
var builder = WebApplication.CreateBuilder(args);
@ -32,7 +33,8 @@ builder.Services.AddCors(c =>
.AllowAnyMethod();//允许任意方法
});
});
// 显示logo
builder.Services.AddLogo();
//注入SignalR实时通讯默认用json传输
builder.Services.AddSignalR();
//消除Error unprotecting the session cookie警告
@ -65,10 +67,12 @@ builder.Services.AddTaskSchedulers();
DbExtension.AddDb(builder.Configuration);
//注册REDIS 服务
Task.Run(() =>
var openRedis = builder.Configuration["RedisServer:open"];
if (openRedis == "1")
{
//RedisServer.Initalize();
});
RedisServer.Initalize();
}
builder.Services.AddMvc(options =>
{
options.Filters.Add(typeof(GlobalActionMonitor));//全局注册
@ -80,8 +84,6 @@ builder.Services.AddMvc(options =>
});
builder.Services.AddSwaggerConfig();
// 显示logo
builder.Services.AddLogo();
var app = builder.Build();
InternalApp.ServiceProvider = app.Services;
@ -119,7 +121,6 @@ app.UseAddTaskSchedulers();
//使用全局异常中间件
app.UseMiddleware<GlobalExceptionMiddleware>();
//设置socket连接
app.MapHub<MessageHub>("/msgHub");

View File

@ -64,6 +64,7 @@
},
//redis
"RedisServer": {
"open": 0, //redis
"Cache": "127.0.0.1:6379,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=cache:",
"Session": "127.0.0.1:6379,defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240,prefix=session:"
},