I understand that there have been several posts about where to add check / update cache and separation of problems between the controller, model and caching code.
There are two great examples that I tried to work with, but am new to MVC. I wonder which one is the cleanest and best suited for the MVC methodology? I know that you need to consider DI and unit testing.
Example 1 (Assistant with a delegate)
... in the controller
var myObject = CacheDataHelper.Get(thisID, () =>
WebServiceServiceWrapper.GetMyObjectBythisID(thisID));
Example 2 (checking the cache in the model class) in the controller
var myObject = WebServiceServiceWrapper.GetMyObjectBythisID(thisID));
then in the model class ..............
if (!CacheDataHelper.Get(cachekey, out myObject)) {
}
--, , . , , .
.
- , MVC. - , - , , ?
, . , , , ?