Allow null values to be cached and refine TryGet method (see #155)#157
Allow null values to be cached and refine TryGet method (see #155)#157EnricoMassone wants to merge 17 commits intoalastairtree:masterfrom
Conversation
removed the null check for the item parameter in the CachingService.Add method
|
Using the IAppCache.TryGetValueAsync method is quite convoluted. Consider this example: The API used must I'm not a big fan of output parameters, because they are basically parameters used to return values outside of a method. Some people consider them as a bad practice. We can maybe consider to refactor the signature of both By doing so, we can write an |
|
Hi, any news on this ? Did you take a canche to review ? |
I have introduced the following changes:
IAppCache.Addmethod allows to cachenullvalues. No exception is thrown.IAppCache.TryGetValuefrombool TryGetValue<T>(string key, out object value);tobool TryGetValue<T>(string key, out T value);IAppCache.TryGetValueso that values cached by usingIAppCache.GetOrAddand / orIAppCache.GetOrAddAsyncare handled correctly (the actual cached value is returned insted of the lazy wrapper).bool TryGetValueAsync<T>(string key, out Task<T> value);used to try fetch values cached by usingIAppCache.GetOrAddAsyncSee issue #155 for the details.