MeiRiYiCheng_1_old/Nirvana.Common/Cache/MyCache.cs

24 lines
589 B
C#
Raw Permalink Normal View History

2025-07-16 17:14:38 +08:00
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
namespace Nirvana.Common
{
public static class MyCache
{
public static IServiceCollection serviceCollection;
public static MemoryCache get
{
get
{
var factory= serviceCollection.BuildServiceProvider().GetService(typeof(IMemoryCache));
MemoryCache cache = (MemoryCache)factory;
return cache;
}
}
}
}