/// <summary>
        /// Configure the cache
        /// </summary>
        /// <param name="regionName">the name of the cache region</param>
        /// <param name="properties">configuration settings</param>
        /// <returns></returns>
        public ICache BuildCache(string regionName, IDictionary <string, string> properties)
        {
            //return a configured cache region if we have one for the region already
            //the only way this will really happen is if there is a query cache specified for a region that is configured
            //since query caches are not configured at session factory startup
            if (String.IsNullOrEmpty(regionName) == false && cacheRegions.ContainsKey(regionName))
            {
                return(cacheRegions[regionName]);
            }

            //build the cache from preconfigured values if the region has configuration values
            if (cacheRegionSettingsList != null)
            {
                CacheRegionElement regionSettings = cacheRegionSettingsList[regionName];

                if (regionSettings != null)
                {
                    SysCacheRegion cacheRegion;

                    lock (regionsSyncRoot)
                    {
                        //note that the only reason we have to do this double check is because the query cache
                        //can try to create caches at unpredictable times
                        if (cacheRegions.TryGetValue(regionName, out cacheRegion) == false)
                        {
                            if (log.IsDebugEnabled)
                            {
                                log.DebugFormat("building cache region, '{0}', from configuration", regionName);
                            }

                            //build the cache region with settings and put it into the list so that this proces will not occur again
                            cacheRegion = new SysCacheRegion(regionName, regionSettings, properties);
                            cacheRegions[regionName] = cacheRegion;
                        }
                    }

                    return(cacheRegion);
                }
            }

            if (log.IsDebugEnabled)
            {
                log.DebugFormat("building non-configured cache region : {0}", regionName);
            }

            //we will end up creating cache regions here for cache regions that nhibernate
            //uses internally and cache regions that weren't specified in the application config file
            return(new SysCacheRegion(regionName, properties));
        }
示例#2
0
        /// <summary>
        /// Configure the cache
        /// </summary>
        /// <param name="regionName">the name of the cache region</param>
        /// <param name="properties">configuration settings</param>
        /// <returns></returns>
        public ICache BuildCache(string regionName, IDictionary<string, string> properties)
        {
            //return a configured cache region if we have one for the region already
            //the only way this will really happen is if there is a query cache specified for a region that is configured
            //since query caches are not configured at session factory startup 
            if (String.IsNullOrEmpty(regionName) == false && cacheRegions.ContainsKey(regionName))
            {
                return cacheRegions[regionName];
            }

            //build the cache from preconfigured values if the region has configuration values
            if (cacheRegionSettingsList != null)
            {
                CacheRegionElement regionSettings = cacheRegionSettingsList[regionName];

                if (regionSettings != null)
                {
                    SysCacheRegion cacheRegion;

                    lock (regionsSyncRoot)
                    {
                        //note that the only reason we have to do this double check is because the query cache 
                        //can try to create caches at unpredictable times
                        if (cacheRegions.TryGetValue(regionName, out cacheRegion) == false)
                        {
                            if (log.IsDebugEnabled)
                            {
                                log.DebugFormat("building cache region, '{0}', from configuration", regionName);
                            }

                            //build the cache region with settings and put it into the list so that this proces will not occur again
                            cacheRegion = new SysCacheRegion(regionName, regionSettings, properties);
                            cacheRegions[regionName] = cacheRegion;
                        }
                    }

                    return cacheRegion;
                }
            }

            if (log.IsDebugEnabled)
            {
                log.DebugFormat("building non-configured cache region : {0}", regionName);
            }

            //we will end up creating cache regions here for cache regions that nhibernate
            //uses internally and cache regions that weren't specified in the application config file
            return new SysCacheRegion(regionName, properties);
        }