2021-11-03 18:26:13 +08:00
|
|
|
|
using log4net;
|
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2022-04-06 22:22:45 +08:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2021-11-03 18:26:13 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2022-04-06 22:22:45 +08:00
|
|
|
|
using Yi.Framework.Common.Models;
|
2021-11-03 18:26:13 +08:00
|
|
|
|
using Yi.Framework.Core;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Yi.Framework.WebCore.MiddlewareExtend
|
|
|
|
|
|
{
|
2022-10-26 20:01:18 +08:00
|
|
|
|
public static class CacheInitExtend
|
2021-11-03 18:26:13 +08:00
|
|
|
|
{
|
2022-10-26 20:01:18 +08:00
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(CacheInitExtend));
|
2022-04-06 22:22:45 +08:00
|
|
|
|
public static void UseRedisSeedInitService(this IApplicationBuilder app )
|
2021-11-03 18:26:13 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
2022-10-26 20:01:18 +08:00
|
|
|
|
if (Appsettings.appBool("CacheSeed_Enabled"))
|
2021-11-03 18:26:13 +08:00
|
|
|
|
{
|
2022-10-17 01:10:31 +08:00
|
|
|
|
var _cacheClientDB = app.ApplicationServices.GetService<CacheInvoker>();
|
2021-11-03 18:26:13 +08:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2022-04-02 17:44:50 +08:00
|
|
|
|
//RedisInit.Seed(_cacheClientDB);
|
2021-11-03 18:26:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
log.Error($"Error occured seeding the RedisInit.\n{e.Message}");
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|