You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
621 B
23 lines
621 B
5 days ago
|
namespace Admin.NET.Core;
|
||
|
|
||
|
public static class CacheSetup
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 缓存注册(新生命Redis组件)
|
||
|
/// </summary>
|
||
|
/// <param name="services"></param>
|
||
|
public static void AddCache(this IServiceCollection services)
|
||
|
{
|
||
|
ICache cache = Cache.Default;
|
||
|
|
||
|
var cacheOptions = App.GetOptions<CacheOptions>();
|
||
|
if (cacheOptions.CacheType == CacheTypeEnum.Redis.ToString())
|
||
|
{
|
||
|
var redis = new FullRedis();
|
||
|
redis.Init(cacheOptions.RedisConnectionString);
|
||
|
cache = redis;
|
||
|
}
|
||
|
|
||
|
services.AddSingleton(cache);
|
||
|
}
|
||
|
}
|