Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesBest approach to caching large number of objects (programming opinons sought)Best approach to caching large number of objects (programming opinons sought)
Previous
 
Next
New Post
5/1/2012 1:03 PM
 

(shamelessly cross posted from the Community Exchange)

I am writing a module that displays a list of items on the page. The database holds (lets say) 50,000 items which are related (many to many) with (lets say) 1000 pages.

Instead of writing a stored procedure to return a set of complete items for a given page from the database (i.e. all columns, in order to hydrate a list of item objects), I am thinking of doing the following to render a list:

  • on application startup, caching all listing items
  • getting the SP to return just the key value for the items
  • looping through the list of keys & retrieving the matching object from cache

Preliminary tests indicate this performs faster than hydrating a list from the DB for each page request. It also seems to cause less overall memory consumption, as each page request would just look up existing objects, as opposed to each request making a private list (when traffic is high and large pages are requested memory consumption gets very high).

So now I am debating with fellow developers how to implement the cache. We have come up with several options, and this is where I would appreciate your opinions:

  1. Use the native ASP.NET HttpContext.Current.Cache
  2. Use the DNN DataCache wrapper
  3. Use static/singleton objects

Within each of these there is also a choice whether to:

        a) Cache each item object individually
        b) Build a dictionary (or similar list) containing all item objects then cache the dictionary

Read performance is the main concern. Maintenance is a secondary concern - we would write our GetItems methods defensively to check if each item is in the cache and if not, retrieve it from the DB and insert it into the cache.

I know there is no right answer ... there are pros & cons for everything. I am just looking to see if people have pitfalls they can share about any of the above, or if any approach stands out as being by far the best performing, or is particularly hard to merge new data into.

Thanks


 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesBest approach to caching large number of objects (programming opinons sought)Best approach to caching large number of objects (programming opinons sought)


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out