配置文件更改
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user