Dear Support,
we have set the cache limit as 15 minutes.
Also as per our functionality, we have fetched two products randomly per member from the database and stored into the cache.
Then we have showed the product from the cache. So randomization of another two products will take every 15 minutes to affect.
If we refresh the page, we want to show another two products. If we reduce the cache limit, page load taking more time. Please advise on this.
After 15 minutes only another two products fetched from the database. But I need to change the product each refresh. so If we use the cache, after 15 minutes only product are changing in the page.
If you need to refresh it on every page request then why do you put it in the Cache in the first place?
I suggest you take all products in cache when starting up your application and on every page request randomly take 2 products and show that. When it comes from Cache it doesn't need to go to the database and make expensive resource calls.
Grz, Kris.
Read my blog | Twitter Working with Azure, chatbots, ASP.NET MVC, Web API, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
If you want to show each time different 2 products then don't put them like this in Cache. At the moment you're saying to ASP.NET to get things out of Cache for the next x minutes. After that put new stuff in the Cache.
Either don't make use of Cache at all or only load, as I suggested before, the productnumbers in Cache and randomly pick from that list on each page request.
Grz, Kris.
Read my blog | Twitter Working with Azure, chatbots, ASP.NET MVC, Web API, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
Member
4 Points
38 Posts
Memory cache problem.
Jul 24, 2015 05:53 AM|devi.zerosoft|LINK
Dear Support,
we have set the cache limit as 15 minutes.
Also as per our functionality, we have fetched two products randomly per member from the database and stored into the cache.
Then we have showed the product from the cache. So randomization of another two products will take every 15 minutes to affect.
If we refresh the page, we want to show another two products. If we reduce the cache limit, page load taking more time. Please advise on this.
All-Star
191741 Points
20952 Posts
ASPInsiders
Moderator
MVP
Re: Memory cache problem.
Jul 24, 2015 06:41 AM|XIII|LINK
Hi,
what exactly is the problem?
When still in the time window of 15 minutes and in cache?
Grz, Kris.
Working with Azure, chatbots, ASP.NET MVC, Web API, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
Member
4 Points
38 Posts
Re: Memory cache problem.
Jul 24, 2015 07:01 AM|devi.zerosoft|LINK
Hi,
After 15 minutes only another two products fetched from the database. But I need to change the product each refresh. so If we use the cache, after 15 minutes only product are changing in the page.
Please let me know still you are not clear.
Thanks,
Devi
All-Star
191741 Points
20952 Posts
ASPInsiders
Moderator
MVP
Re: Memory cache problem.
Jul 24, 2015 07:20 AM|XIII|LINK
Hi,
If you need to refresh it on every page request then why do you put it in the Cache in the first place?
I suggest you take all products in cache when starting up your application and on every page request randomly take 2 products and show that. When it comes from Cache it doesn't need to go to the database and make expensive resource calls.
Grz, Kris.
Working with Azure, chatbots, ASP.NET MVC, Web API, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
Member
4 Points
38 Posts
Re: Memory cache problem.
Jul 24, 2015 07:37 AM|devi.zerosoft|LINK
Hi,
Query returns the below result.
ProductId UserId
18683 39
18636 39
18060 148
18012 148
4068 247
4069 247
If we store all the products cache means, then please explain how we can show two products per user, and another refresh another two products.
Shall we need to handle this in coding side. If possible please suggest me with the sample code.
Thanks for your help!
All-Star
191741 Points
20952 Posts
ASPInsiders
Moderator
MVP
Re: Memory cache problem.
Jul 24, 2015 09:21 AM|XIII|LINK
Hi,
If you want to show each time different 2 products then don't put them like this in Cache. At the moment you're saying to ASP.NET to get things out of Cache for the next x minutes. After that put new stuff in the Cache.
Either don't make use of Cache at all or only load, as I suggested before, the productnumbers in Cache and randomly pick from that list on each page request.
Grz, Kris.
Working with Azure, chatbots, ASP.NET MVC, Web API, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!