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

Feature Request: CachingService virtual methods (legacy 0.7) #70

Closed rondelward closed 5 years ago

rondelward commented 5 years ago

I'm stuck using LazyCache 0.7.1.44 for a while because I'm currently unable to upgrade by app to .Net Standard or .Net Core anytime soon. I'm hoping that a minor update to the 0.7 version is still possible but understand if it isn't feasible at this time.

Could the public methods in CachingService be marked as virtual in the legacy version as well? I see this change in version 2 of the API but the older version isn't marked as virtual. e.g. public virtual void Remove(string key) vs public void Remove(string key)

I have some additional functionality added in a custom caching service that better fits an inherited class with an override than it does a decorator or another pattern. My current workaround is to copy the source code of CachingService and mark the methods virtual myself in the copied class. Though this "works", I feel like it a bit distracting from the actual intent of the class and might cause some confusion when we are in a better position to upgrade to version 2 later.

Is this something that can be done? Let me know what you think or if you have an alternative suggestion.

Update: My fault. I can in fact use version 2 because I'm on 4.6.1 🤦‍♂

alastairtree commented 5 years ago

Glad you could upgrade, but if you, or someone else, did want to submit a PR for this I would happily merge and release.