NSoft.NFramework.Caching.SharedCache.NHCaches.SharedCacheProvider.BuildCache C# (CSharp) Method

BuildCache() public method

Configure the cache
public BuildCache ( string regionName, string>.IDictionary properties ) : ICache
regionName string the name of the cache region
properties string>.IDictionary configuration settings
return ICache
        public ICache BuildCache(string regionName, IDictionary<string, string> properties) {
            if(regionName == null)
                regionName = string.Empty;

            ICache result;
            if(_caches.TryGetValue(regionName, out result))
                return result;

            var props = properties ?? new Dictionary<string, string>(1);

            if(IsDebugEnabled) {
                var sb = new StringBuilder();
                sb.AppendFormat("Build SharedCacheProvider with region:[{0}], properties:", regionName);

                foreach(var pair in props)
                    sb.AppendFormat("name={0}&value={1};", pair.Key, pair.Value);

                log.Debug(sb.ToString());
            }

            return new SharedCacheClient(regionName, props);
        }

Usage Example

Example #1
0
        public void Build_Cache_From_AppConfig()
        {
            const string Region = @"NSoft.NFramework.Caching.SharedCache";

            ICache cache = _provider.BuildCache(Region, null);

            Assert.IsNotNull(cache);
            Assert.AreEqual(Region, cache.RegionName);
        }
All Usage Examples Of NSoft.NFramework.Caching.SharedCache.NHCaches.SharedCacheProvider::BuildCache