alastairtree / LazyCache

An easy to use thread safe in-memory caching service with a simple developer friendly API for c#
https://nuget.org/packages/LazyCache
MIT License
1.72k stars 159 forks source link

Refactor LazyCache to support the Options Pattern #128

Open alastairtree opened 4 years ago

alastairtree commented 4 years ago

[Use the Thumbs Up reaction to vote for this feature, and please avoid adding comments like "+1" as they create noise for others watching the issue.]

LazyCache currently uses statics for some config such as default cache duration because of the age of the project. Remove all statics and instead use the more modern Options pattern with a strongly types options object which is more common in dotnet core. See https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-3.1

CachingService should add a constructor dependency on IOptions<LazyCacheOptions> options. LazyCacheOptions should have a properties for DefaultCacheDuration and NumberOfKeyLocks and anything else configurable.

This is a breaking change - requires a major version increase