Open DanielTulpWE opened 1 year ago
I have figured out a way to do it, not entirely sure yet that LazyCache will use this configuration, maybe @alastairtree can confirm this
/// <summary>
/// Our caching implementation
/// </summary>
public class OurLazyCaching : CachingService
{
/// <summary>
/// Our custom caching options, configure in appsettings?
/// </summary>
private static readonly IOptions<MemoryCacheOptions> _options = new MemoryCacheOptions
{
SizeLimit = 1024 // unitless size
};
/// <summary>
/// Constructor that applies our custom caching options
/// </summary>
public OurLazyCaching() :
base(new Lazy<ICacheProvider>(() =>
new MemoryCacheProvider(new MemoryCache(_options))
)
)
{
}
}
And than use this in the denpendency injection
services.AddSingleton<IAppCache, OurLazyCaching>();
In MemoryCache by Microsoft we can do things like
or
Is there a way to limit the total size of the LazyCache?
If not, this should be your next feature to implement in my opinion.
This is why it is important