完成redis

This commit is contained in:
lzw
2021-11-03 18:26:13 +08:00
parent 7b994240d0
commit c4e13a4135
14 changed files with 115 additions and 265 deletions

View File

@@ -6,8 +6,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Model.DbInit;
using Yi.Framework.Model.ModelFactory;
using Yi.Framework.WebCore.Init;
namespace Yi.Framework.WebCore.MiddlewareExtend
{

View File

@@ -4,6 +4,7 @@ using Microsoft.OpenApi.Models;
using System;
using System.IO;
using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Core;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
@@ -17,6 +18,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
if (Appsettings.appBool("Redis_Enabled"))
{
services.Configure<RedisConnOptions>(Appsettings.appConfiguration("RedisConn"));
services.AddTransient<CacheClientDB>();
}
return services;
}

View File

@@ -0,0 +1,37 @@
using log4net;
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Core;
using Yi.Framework.Model.ModelFactory;
using Yi.Framework.WebCore.Init;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
public static class RedisInitExtend
{
private static readonly ILog log = LogManager.GetLogger(typeof(RedisInitExtend));
public static void UseRedisInitService(this IApplicationBuilder app, CacheClientDB _cacheClientDB)
{
if (Appsettings.appBool("RedisSet_Enabled"))
{
if (app == null) throw new ArgumentNullException(nameof(app));
try
{
RedisInit.Seed(_cacheClientDB);
}
catch (Exception e)
{
log.Error($"Error occured seeding the RedisInit.\n{e.Message}");
throw;
}
}
}
}
}