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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to Cache items permanentlyHow to Cache items permanently
Previous
 
Next
New Post
11/25/2008 3:41 PM
 

I am not sure if I am heading in the right direction.

I have a list which is used very frequently and I want to cache it for performance reasons.

 

DotNetNuke.Services.Cache.CachingProvider.Instance().Insert("MyList", object, true);

With the above statement, can I expect "MyList" to survive app restart(which means, if app restarts, I dont have to query it from the database?)

and does this list expire (removed from cache) in a specified time?

How do I make it to stay in the cache forever?

 

Please let me know..

TIA

 
New Post
11/25/2008 5:03 PM
 

Try this:

                CachingProvider.Instance().Insert(
                    "MyList",
                    object,
                    null, // dependencies
                    Cache.NoAbsoluteExpiration,
                    Cache.NoSlidingExpiration,
                    CacheItemPriority.NotRemovable,
                    null, // Callback handler if removed.
                    true);

Dirk

 
New Post
11/25/2008 6:22 PM
 

In general you let the host decide what the lifetime in the cache should be, so it is considered 'rude' to override others by plugging in the cache and telling the caching engine: "hey I'm real important, you got to keep me forever". Instead you take the parameters as set by the host as a basis for caching. The pattern most often used in DNN is as follows:

  • You make a method along the lines of GetMyList()
  • You set a variable to what you need to return and set it to null
  • Attempt to retrieve from the caching engine the cached value
  • IF the return var is still null, construct it and add it to the cache using your rule
  • Return the var

This is a very robust and friendly way to handle caching in DNN. Remember there are potentially other developers 'next to you' (i.e. other modules) that also use the cache. Sticking to 'best practice' ensures that the end users get the best performance from the framework as the DNN core developers assume this is what you do.

My 2cts on this ...


Peter Donker
Bring2mind http://www.bring2mind.net
Home of the Document Exchange,
the professional document management solution for DNN
 
New Post
11/25/2008 6:48 PM
 

HEre is my code on how to cache. Bear in mind that DNN 4.9 has a major bug in it and caching does not work (although I believe this is scheduler related.


Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
New Post
11/25/2008 11:14 PM
 

Peter Donker wrote

In general you let the host decide what the lifetime in the cache should be, so it is considered 'rude' to override others by plugging in the cache and telling the caching engine: "hey I'm real important, you got to keep me forever". Instead you take the parameters as set by the host as a basis for caching. The pattern most often used in DNN is as follows:

  • You make a method along the lines of GetMyList()
  • You set a variable to what you need to return and set it to null
  • Attempt to retrieve from the caching engine the cached value
  • IF the return var is still null, construct it and add it to the cache using your rule
  • Return the var

This is a very robust and friendly way to handle caching in DNN. Remember there are potentially other developers 'next to you' (i.e. other modules) that also use the cache. Sticking to 'best practice' ensures that the end users get the best performance from the framework as the DNN core developers assume this is what you do.

My 2cts on this ...

 

I agree Peter..I have some of my lists loaded this way..I check if its in cache, if not, add it to cache and use it..but I was trying to avoid doing that also as my lists wont change really..

 

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to Cache items permanentlyHow to Cache items permanently


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