Example #1
0
        public void TestGetConfig()
        {
            var section = SysCacheSection.GetSection();

            Assert.That(section.CacheRegions, Has.Count.EqualTo(4), "Unexpected region count");
            var region = section.CacheRegions[0];

            Assert.That(region.Name, Is.EqualTo("foo"), "Unexpected region name");
            Assert.That(region.Priority, Is.EqualTo(CacheItemPriority.AboveNormal), "Unexpected region priority");
            Assert.That(region.RelativeExpiration, Is.EqualTo(TimeSpan.FromSeconds(500)), "Unexpected region relative expiration");
            Assert.That(region.UseSlidingExpiration, Is.EqualTo(true), "Unexpected region use sliding expiration");
        }
        /// <summary>
        /// Initializes the <see cref="SysCacheProvider"/> class.
        /// </summary>
        static SysCacheProvider()
        {
            //we need to determine which cache regions are configured in the configuration file, but we cant create the
            //cache regions at this time becasue there could be nhibernate configuration values
            //that we need for the cache regions such as connection info to be used for data dependencies, but this info
            //isnt available until until build cache is called.  So allocte space but only create them on demand

            SysCacheSection configSection = SysCacheSection.GetSection();

            if (configSection != null && configSection.CacheRegions.Count > 0)
            {
                cacheRegionSettingsList = configSection.CacheRegions;
                cacheRegions            = new Dictionary <string, SysCacheRegion>(cacheRegionSettingsList.Count);
            }
            else
            {
                cacheRegions = new Dictionary <string, SysCacheRegion>(0);
                log.Info(
                    "No cache regions specified. Cache regions can be specified in sysCache configuration section with custom settings.");
            }
        }