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

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Cache QuestionCache Question
Previous
 
Next
New Post
7/17/2007 11:41 AM
 

        I'm buidling a custom C# DNN module and have implemented caching:

        public static List<TestInfo> GetCached(int ModuleId, HttpContext myContext, ControlCachePolicy myCachePolicy)
        {
            string key = "TestCache" + ModuleId.ToString();
            object cacheItems = myContext.Cache.Get(key);
            if (cacheItems == null)
            {
                TestController controller = new TestController();
                cacheItems = controller.GetTest(ModuleId);
                DateTime cacheDuration = DateTime.Now.AddHours(2.00);
                if (myCachePolicy.SupportsCaching == true)
                {
                    cacheDuration = DateTime.Now.AddHours(myCachePolicy.Duration.Hours);
                }
                myContext.Cache.Insert(key, cacheItems, null, cacheDuration, TimeSpan.Zero);

            }
            return (List<TestInfo>)cacheItems;
        }

What I am storing in cache, List<TestInfo>, is relatively small compared to what I would like to cache. Each item in this List contains an ItemId. Using the ItemId, I call the database to retrieve an object. This object can be large and I can see where there may be 100, 200, or more of these objects that would be cached.

Does it make sense to cache that many large objects? What would be the downside of doing so? I know that the upside would be less calls to stored procedures in the database.

 

 
New Post
7/17/2007 11:49 AM
 

The biggest downside in my mind is that caching uses system memory, if you are caching a ton of stuff -- you could eat up all of the machine's memory and thats generally not a good thing.....

so...use caching sparingly, and it will be up to you to determine what exactly sparingly means in your specific context....(how much system memory you have...how much of it you will probably be using....how much of it you are willing to use....etc...)

hope that helps!

Ian


Software Engineer
Co-Founder, dnnGallery
Stack Overflow: Ian Robinson
Twitter: @irobinson
Linked In: Ian Robinson
 
New Post
7/17/2007 11:53 AM
 

Another possible downside I just thought of is that you risk having stale data....but you appear to be taking care of that by setting expiration limits....

-Ian


Software Engineer
Co-Founder, dnnGallery
Stack Overflow: Ian Robinson
Twitter: @irobinson
Linked In: Ian Robinson
 
New Post
7/17/2007 12:13 PM
 

Wouldn't the cache automatically be released as system memory ran out?

 
New Post
7/18/2007 4:31 PM
 

nickka2,

the following blog post articulates the concerns I brought forward much more nicely:

http://blogs.techrepublic.com.com/programming-and-development/?p=442

-Ian


Software Engineer
Co-Founder, dnnGallery
Stack Overflow: Ian Robinson
Twitter: @irobinson
Linked In: Ian Robinson
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Cache QuestionCache Question


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