配置文件更改

This commit is contained in:
陈淳
2022-10-26 20:01:18 +08:00
parent fd9f3d04d9
commit 3a634d7888
11 changed files with 577 additions and 248 deletions

View File

@@ -0,0 +1,34 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using System;
using System.IO;
using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Core;
using Yi.Framework.Core.Cache;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
/// <summary>
/// Redis扩展
/// </summary>
public static class CacheExtension
{
public static IServiceCollection AddCacheService(this IServiceCollection services)
{
var cacheSelect= Appsettings.app("CacheSelect");
switch (cacheSelect) {
case "Redis":
services.Configure<RedisConnOptions>(Appsettings.appConfiguration("RedisConnOptions"));
services.AddSingleton<CacheInvoker, RedisCacheClient>();
break;
case "MemoryCache":
services.AddSingleton<CacheInvoker, MemoryCacheClient>();
break;
default:throw new ArgumentException("CacheSelect配置填的是什么东西俺不认得");
}
return services;
}
}
}

View File

@@ -12,13 +12,13 @@ using Yi.Framework.Core;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
public static class RedisInitExtend
public static class CacheInitExtend
{
private static readonly ILog log = LogManager.GetLogger(typeof(RedisInitExtend));
private static readonly ILog log = LogManager.GetLogger(typeof(CacheInitExtend));
public static void UseRedisSeedInitService(this IApplicationBuilder app )
{
if (Appsettings.appBool("RedisSeed_Enabled"))
if (Appsettings.appBool("CacheSeed_Enabled"))
{
var _cacheClientDB = app.ApplicationServices.GetService<CacheInvoker>();

View File

@@ -1,26 +0,0 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using System;
using System.IO;
using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Core;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
/// <summary>
/// Redis扩展
/// </summary>
public static class RedisExtension
{
public static IServiceCollection AddRedisService(this IServiceCollection services)
{
if (Appsettings.appBool("Redis_Enabled"))
{
services.Configure<RedisConnOptions>(Appsettings.appConfiguration("RedisConnOptions"));
services.AddSingleton<CacheInvoker>();
}
return services;
}
}
}