CacheManager icon indicating copy to clipboard operation
CacheManager copied to clipboard

Flag BaseCacheManager methods as virtual to allow overrides.

Open jthope opened this issue 6 years ago • 2 comments

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.

jthope avatar Jul 04 '19 17:07 jthope

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.

MichaCo avatar Jul 05 '19 09:07 MichaCo

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

jthope avatar Jul 05 '19 17:07 jthope