22 lines
641 B
C#
22 lines
641 B
C#
using Microsoft.Extensions.Caching.Memory;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
|
|
namespace YD_XinWei.Commons.MemoryCaches
|
|
{
|
|
public static class MemoryCacheSetup
|
|
{
|
|
public static void AddMemoryCacheSetup(this IServiceCollection services)
|
|
{
|
|
if (services == null) throw new ArgumentNullException(nameof(services));
|
|
|
|
services.AddScoped<ICaching, MemoryCaching>();
|
|
services.AddScoped<IMemoryCache>(factory =>
|
|
{
|
|
var cache = new MemoryCache(new MemoryCacheOptions());
|
|
return cache;
|
|
});
|
|
}
|
|
}
|
|
}
|