nopSolutions / nopCommerce

ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
https://www.nopcommerce.com
Other
9.08k stars 5.19k forks source link

MemoryCacheManager.GetAsync method can cache null value #7238

Closed skoshelev closed 2 weeks ago

skoshelev commented 2 weeks ago

nopCommerce version: 4.70

We have always avoided caching null values since they usually arise due to errors. But, in the course of optimizing the work of caching in memory, we missed this point for the GetAsync method in the signature Task<T> GetAsync<T>(CacheKey key, Func<Task<T>> acquire) moreover, this method is in the signature Task<T> GetAsync<T>(CacheKey key, Func<T> acquire) provided that acquire returns the null, it will generally cause a NullReferenceException, which is not at all predictable

example: https://www.nopcommerce.com/en/boards/topic/99319/issue-with-product-pagination-and-price-display-in-nopcommerce-470

skoshelev commented 2 weeks ago

Closed #7238