/// <summary> /// Constructor of MemoryDistributedCache /// </summary> /// <param name="optionsAccessor"> /// IOptions <see cref="MemoryDistributedCacheOptions" /> optionsAccessor /// </param> public CommonMemoryDistributedCache(IOptions <MemoryDistributedCacheOptions> optionsAccessor) : base(optionsAccessor, NullLoggerFactory.Instance) { if (optionsAccessor == null) { throw new ArgumentNullException(nameof(optionsAccessor)); } if (!MemoryCacheServiceCollectionExtensions.IsAdded()) { _memoryCache ??= new MemoryCache(optionsAccessor.Value); } }
/// <summary> /// 加载此服务 /// </summary> /// <param name="services"></param> public static IServiceCollection AddMemoryCache(this IServiceCollection services) { StartUp.Run(); MemoryCacheServiceCollectionExtensions.AddMemoryCache(services); return(services); }