Data Caching chances of returning null value from function

pienueovapado

New Member
I have a function written in C# which return collection of business-entity (make) after checking and inserting in cache.
\[code\] public static Collection<CProductMakesProps> GetCachedSmartPhoneMake(HttpContext context) { var allMake = context.Cache["SmartPhoneMake"] as Collection<CProductMakesProps>; if (allMake == null) { context.Cache.Insert("SmartPhoneMake", new CModelRestrictionLogic().GetTopMakes(), null, DateTime.Now.AddHours(Int32.Parse(ConfigurationManager.AppSettings["MakeCacheTime"])), Cache.NoSlidingExpiration); allMake = context.Cache["SmartPhoneMake"] as Collection<CProductMakesProps>; } return allMake; }\[/code\]I am using it in some other page as follows\[code\] var lobjprodMakeCol = CBrandCache.GetCachedSmartPhoneMake(Context); //CBrandCache is the class which contain the method \[/code\]Is it possible that I get null value in the \[code\]lobjprodMakeCol\[/code\] Thanks.
 
Back
Top