MichaCo / CacheManager

CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
http://cachemanager.michaco.net
Apache License 2.0
2.35k stars 456 forks source link

Flag BaseCacheManager methods as virtual to allow overrides. #280

Open jthope opened 5 years ago

jthope commented 5 years ago

I am wrapping the BaseCacheManager<> object to customize key values. Several methods allow overrides (Get, Put, Add, etc). However, there are some really nice helper methods that cannot be overridden.

Example of the wrapper in an external project: image

Example do flagging addtl helper methods in BaseCacheManager as virtual: image

Since I am new to the project, I may be overlooking something. But my goal is to modify the key before any cache requests. At first thought, hooking into the various events for cache operations (OnAdd, OnRemove, etc) I could do this, but they key is readonly here, and that's probably a safety measure. Do you see any issue with marking the additional caching methods in the BaseCacheManager class as virtual?

I could submit a PR if not. I only have a few hours of familiarity with this project, so I don't know the implications this may have on the design strategy of the CacheManager project.

MichaCo commented 5 years ago

Hi @jthope, I think you actually only have to override the 4 protected methods for Get/Put/Add/Delete Internal. Those methods are invoked from basically everything else. Except, updates. Those work slightly different and for some reason are not virtual/protected. I guess if you need those, too, I wouldn't disagree to change the access level for those.

jthope commented 5 years ago

I will take a look, thank your for the quick reply!