Display Recent Items for the user efficiently

Last post 11-12-2009 6:42 PM by zmarji. 3 replies.

Sort Posts:

  • Display Recent Items for the user efficiently

    11-12-2009, 12:28 PM

    We have an ASP.NET web application in which we would like to provide a list of 10 recently accessed items by that user when that user is logged in.

    As far as the table design, I created the following schema to store who accessed what entity at what time.
          [RecentItemsGUID] [uniqueidentifier] NOT NULL,
          [PersonGUID] [uniqueidentifier] NOT NULL,
          [EntityTypeID] [tinyint] NOT NULL,
          [EntityGUID] [uniqueidentifier] NOT NULL,
          [AccessDate] [datetime] NOT NULL,

    I can add a control on the master page that will show the recently accessed item.  But, instead of loading this information on every page load from the database, I would like to cache this information for each user.  I looked at the OutputCache directive and placing this information in a UserControl, then I can use the varybycustom attribute.  But when the user goes to another page and accesses another entity, how should I mark this cache dirty so that next time the usercontrol is loaded, it makes a DB call and retrieves the new items.  I cannot really use the SystemUserGUID stored in the cookie for the varybycustom parameter because I want the list to update every time the user interacts with a new entity.

    If anyone can provide some suggestions on how to accomplish this in the most efficient manner, that will be great.



     

  • Re: Display Recent Items for the user efficiently

    11-12-2009, 1:16 PM
    • Participant
      878 point Participant
    • dangerouschotu
    • Member since 10-11-2008, 12:10 PM
    • Jaipur
    • Posts 318

    you can get all the data from the database in a DataTable and add this data table in the session named "abc" and bind as you want and put a check on the code if the session"abc" is NULL then reload to the database otherwise get session value in the database and bind it.

    other solution is to creata an xml file on the client side and load from the xml file.. i think so. 

    Thanks & Regards,
    Please 'mark as answer' my post if they are helpful.
  • Re: Display Recent Items for the user efficiently

    11-12-2009, 2:04 PM

    Thanks for your reply, Dangerouschotu.

    I should have mentioned this in my first post that we are not using Session.

    Also, the actual problem is as soon as the user interacts with a new entity, the recent items list needs to be populated again

    to reflect the changes to the recent items

    Pratik

  • Re: Display Recent Items for the user efficiently

    11-12-2009, 6:42 PM
    • Member
      213 point Member
    • zmarji
    • Member since 06-28-2007, 5:35 PM
    • Posts 55

    I hope I understood the problem correctly but I would try something along these lines. The first time you hit the DB, create a cookie with the record count that you get from the db [say dbCount] and a variable for accessed items [say userCount], when the user selects another item update the cookie param [userCount], if the [userCount] is greater than [dbCount] then the control calls the DB and gets the new list otherwise it does not and you can used your cached data. To update the control on the fly once the user selects a new entity use jquery and ajax to do the check (you can use a webservice or wcf or something like that) and make an asynchronous call to the db if needed then update your data and your [dbCount] variable on the cookie.


    Hope this helps

Page 1 of 1 (4 items)