Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/CacheExtension.cs
(完整代码) 1KBusing 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;
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
