Exemple #1
0
        private void InitializeConfiguration(NameValueCollection config)
        {
            MemoryCacheElement element = null;

            if (!_memoryCache.ConfigLess)
            {
                MemoryCacheSection section = ConfigurationManager.GetSection("system.runtime.caching/memoryCache") as MemoryCacheSection;
                if (section != null)
                {
                    element = section.NamedCaches[_memoryCache.Name];
                }
            }

            if (element != null)
            {
                _configCacheMemoryLimitMegabytes     = element.CacheMemoryLimitMegabytes;
                _configPhysicalMemoryLimitPercentage = element.PhysicalMemoryLimitPercentage;
                double milliseconds = element.PollingInterval.TotalMilliseconds;
                _configPollingInterval = (milliseconds < (double)Int32.MaxValue) ? (int)milliseconds : Int32.MaxValue;
            }
            else
            {
                _configPollingInterval               = ConfigUtil.DefaultPollingTimeMilliseconds;
                _configCacheMemoryLimitMegabytes     = 0;
                _configPhysicalMemoryLimitPercentage = 0;
            }

            if (config != null)
            {
                _configPollingInterval               = ConfigUtil.GetIntValueFromTimeSpan(config, ConfigUtil.PollingInterval, _configPollingInterval);
                _configCacheMemoryLimitMegabytes     = ConfigUtil.GetIntValue(config, ConfigUtil.CacheMemoryLimitMegabytes, _configCacheMemoryLimitMegabytes, true, Int32.MaxValue);
                _configPhysicalMemoryLimitPercentage = ConfigUtil.GetIntValue(config, ConfigUtil.PhysicalMemoryLimitPercentage, _configPhysicalMemoryLimitPercentage, true, 100);
            }
        }
Exemple #2
0
        private void InitializeConfiguration(NameValueCollection config)
        {
            MemoryCacheElement element = null;

            if (!this._memoryCache.ConfigLess)
            {
                MemoryCacheSection section = ConfigurationManager.GetSection("system.runtime.caching/memoryCache") as MemoryCacheSection;
                if (section != null)
                {
                    element = section.NamedCaches[this._memoryCache.Name];
                }
            }
            if (element != null)
            {
                this._configCacheMemoryLimitMegabytes     = element.CacheMemoryLimitMegabytes;
                this._configPhysicalMemoryLimitPercentage = element.PhysicalMemoryLimitPercentage;
                double totalMilliseconds = element.PollingInterval.TotalMilliseconds;
                this._configPollingInterval = (totalMilliseconds < 2147483647.0) ? ((int)totalMilliseconds) : 0x7fffffff;
            }
            else
            {
                this._configPollingInterval               = 0x1d4c0;
                this._configCacheMemoryLimitMegabytes     = 0;
                this._configPhysicalMemoryLimitPercentage = 0;
            }
            if (config != null)
            {
                this._configPollingInterval               = ConfigUtil.GetIntValueFromTimeSpan(config, "pollingInterval", this._configPollingInterval);
                this._configCacheMemoryLimitMegabytes     = ConfigUtil.GetIntValue(config, "cacheMemoryLimitMegabytes", this._configCacheMemoryLimitMegabytes, true, 0x7fffffff);
                this._configPhysicalMemoryLimitPercentage = ConfigUtil.GetIntValue(config, "physicalMemoryLimitPercentage", this._configPhysicalMemoryLimitPercentage, true, 100);
            }
        }
Exemple #3
0
        private void InitializeConfiguration(NameValueCollection config)
        {
            MemoryCacheElement element = null;

            if (!_memoryCache.ConfigLess && _configSupported)
            {
                MemoryCacheSection section = ConfigurationManager.GetSection("system.runtime.caching/memoryCache") as MemoryCacheSection;
                if (section != null)
                {
                    element = section.NamedCaches[_memoryCache.Name];
                }
            }

            if (element != null && _configSupported)
            {
                _configCacheMemoryLimitMegabytes     = element.CacheMemoryLimitMegabytes;
                _configPhysicalMemoryLimitPercentage = element.PhysicalMemoryLimitPercentage;
                double milliseconds = element.PollingInterval.TotalMilliseconds;
                _configPollingInterval = (milliseconds < (double)int.MaxValue) ? (int)milliseconds : int.MaxValue;
            }
            else
            {
                _configPollingInterval               = ConfigUtil.DefaultPollingTimeMilliseconds;
                _configCacheMemoryLimitMegabytes     = 0;
                _configPhysicalMemoryLimitPercentage = 0;
            }

            if (config != null)
            {
                _configPollingInterval               = ConfigUtil.GetIntValueFromTimeSpan(config, ConfigUtil.PollingInterval, _configPollingInterval);
                _configCacheMemoryLimitMegabytes     = ConfigUtil.GetIntValue(config, ConfigUtil.CacheMemoryLimitMegabytes, _configCacheMemoryLimitMegabytes, true, int.MaxValue);
                _configPhysicalMemoryLimitPercentage = ConfigUtil.GetIntValue(config, ConfigUtil.PhysicalMemoryLimitPercentage, _configPhysicalMemoryLimitPercentage, true, 100);
            }
#if !NETCOREAPP
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && _configPhysicalMemoryLimitPercentage > 0)
            {
                throw new PlatformNotSupportedException(SR.PlatformNotSupported_PhysicalMemoryLimitPercentage);
            }
#endif
        }