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...Profile Caching in 4.5.1+Profile Caching in 4.5.1+
Previous
 
Next
New Post
6/5/2007 6:03 AM
 

Hi,

Can anyone tell me a little more about profile caching? The reason I ask is that I introduced profile caching in all my modules in the last 2 monthsand I want to see if I can remove it or if I need to be aware of anything,.

Basically whenever I retrieved a user with UserController.GetUser(UserID) I noticed it made 4 hits to the DB. Sometimes I get back 50 profiles at a time and the DB traffic was going mad, so I implemented caching.

It now does a check and if the user is already in the cache it gets it from there or gets it from the DB and adds it to the cache - eg.:

        public UserInfo GetUserFromCacheOrDB(int portalID, int userID, int profileCacheSeconds)
        {
            //check if caching must be used - check if this user record is in the cache, and use it
            string cacheKey = portalID.ToString() + "UserID" + userID.ToString();
            UserInfo user;

            bool userInCache = (DataCache.GetCache(cacheKey) != null);

            if (profileCacheSeconds > 0 && userInCache)
            {
                user = (UserInfo)DataCache.GetCache(cacheKey);
            }
            else
            {
                //get it from the DB
                user = new UserController().GetUser(portalID, userID);

                if (user != null && profileCacheSeconds > 0 && !userInCache)
                {
                    DataCache.SetCache(cacheKey, user, DateTime.Now.AddSeconds(profileCacheSeconds));
                }
            }
            return user;
        }

 

It is configurable in all my modules and I chose abosulte caching over sliding as mysite has heavy traffic and it would never update. Can someone tell me a little more about how the core profile caching works (I noticed the method name in an error somewhere). TIA


Entrepreneur

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

 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Profile Caching in 4.5.1+Profile Caching in 4.5.1+


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