-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow null values to be cached and refine TryGet method (see #155) #157
base: master
Are you sure you want to change the base?
Allow null values to be cached and refine TryGet method (see #155) #157
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.Add
method allows to cachenull
values. No exception is thrown.IAppCache.TryGetValue
frombool TryGetValue<T>(string key, out object value);
tobool TryGetValue<T>(string key, out T value);
IAppCache.TryGetValue
so that values cached by usingIAppCache.GetOrAdd
and / orIAppCache.GetOrAddAsync
are 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.GetOrAddAsync
See issue #155 for the details.