using Admin.Core.Common;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using System;
namespace Admin.Core.Extensions
{
///
/// Memory缓存 启动服务
///
public static class MemoryCacheSetup
{
public static void AddMemoryCacheSetup(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
services.AddScoped();
services.AddSingleton(factory =>
{
var cache = new MemoryCache(new MemoryCacheOptions());
return cache;
});
}
}
}