Are the SharePoint Service Locator mappings cached?

May 4, 2010 at 9:19 AM
Hi all, When getting the current service locator such as this... IServiceLocator serviceLocator = SharePointServiceLocator.GetCurrent(); ILogger logger = serviceLocator.GetInstance<ILogger>(); ... will this cause any calls to the content database where the mappings are stored? Are there any performance considerations when doing this or are the mappings cached? Thanks, Christoffer
May 4, 2010 at 10:40 AM

Hi Christoffer,

We support storing mappings at both the site and farm levels, and we store the settings in property bags.  The farm mappings are loaded once and cached in memory.  The site settings had to be managed differently.  When a farm feature is deployed, we can count on the app domain being recycled which will cause us to reload settings, but we can't at the site level.  We therefore cache the site level settings for a fixed period of time.  The default cache interval is for a site collection is 60 seconds, although the setting is configurable (a farm level configuration setting) and can be set using the ServerLocatorConfig.  We therefore read every 60 seconds for each site collection where service locator is being used.