Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Commerce Server 2009 Site Profile Cache coherency implementaion


Summary

In Microsoft Commerce Server 2009,  a change has been made in the web farm scenario Profile Cache Coherency implementation, compared to Microsoft Commerce Server 2007.

In Microsoft Commerce Server 2007, you needed to call Profile.Refresh() to retrieve profile data from the database and update the local cache on one webserver when the cookie in HTTP requests has a later timestamp than the one in the Profile record in the profile cache.

In Microsoft Commerce Server 2009, queryUser.SearchCriteria.Model.DateModified is used to determine if a profile needs to be refreshed in the Commerce Server  foundation APIs. A cookie needs to be assigned with a timestamp when the profile is updated, and then queryUser.SearchCriteria.Model.DateModified is assigned to the timestamp stored in the cookie before a profile is queried. Due to this change, Commerce Server profiles in the cache are synchronized among the web servers in a web farm.

 

↑ Back to the top


More Information

The Commerce Server 2009 sample site uses an Http cookie, called __UserDateCookie, to set this property and pass it in a UserProfile query.   The foundation API then checks this property against the locally cached profile and does an explicit database roundtrip if needed. 

 

Commerce Server 2009 sample code from the sample site:

 

          // Does the user have a cache coherency cookie?

            if (SiteContext.Current.IsUserDateModifiedCookieSet)

            {

                // cookie found - use the last modified date in the cookie to determine if

                // a cache refresh is required in the operation service.

                queryUser.SearchCriteria.Model.DateModified = SiteContext.Current.UserDateModified;

            }

            else

            {

                // no cookie present.  Force a cache refresh and set the cache coherency

                // cookie for this user.

                queryUser.SearchCriteria.Model.DateModified = DateTime.MaxValue; //// force cache refresh

            }

 

 

For further information on how this change has been implemented in the Commerce Server 2009 sample site, please see the following classes in the Extensibility Kit:

  •       ProfileController
  •       SiteContext
  •       DefaultSessionProvider

 

 

↑ Back to the top


Keywords: vkball, kb

↑ Back to the top

Article Info
Article ID : 2300477
Revision : 1
Created on : 1/8/2017
Published on : 8/6/2010
Exists online : False
Views : 119