locked
Memory cache problem. RRS feed

  • Question

  • User-644563421 posted

    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.

    Friday, July 24, 2015 5:53 AM

Answers

  • User541108374 posted

    Hi,

    and another refresh another two products.

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 24, 2015 9:21 AM

All replies

  • User541108374 posted

    Hi,

    what exactly is the problem?

    If we refresh the page, we want to show another two products

    When still in the time window of 15 minutes and in cache?

    Grz, Kris.

    Friday, July 24, 2015 6:41 AM
  • User-644563421 posted

    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

    Friday, July 24, 2015 7:01 AM
  • User541108374 posted

    Hi,

    But I need to change the product each refresh.

    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.

    Friday, July 24, 2015 7:20 AM
  • User-644563421 posted

    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!

    Friday, July 24, 2015 7:37 AM
  • User541108374 posted

    Hi,

    and another refresh another two products.

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 24, 2015 9:21 AM