2021-11-03 18:26:13 +08:00
|
|
|
|
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));
|
2021-11-03 18:58:44 +08:00
|
|
|
|
public static void UseRedisSeedInitService(this IApplicationBuilder app, CacheClientDB _cacheClientDB)
|
2021-11-03 18:26:13 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
2021-11-03 18:58:44 +08:00
|
|
|
|
if (Appsettings.appBool("RedisSeed_Enabled"))
|
2021-11-03 18:26:13 +08:00
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|