static SoodaCache() { string cachingPolicy = SoodaConfig.GetString("sooda.cachingPolicy", "none"); string cacheType = SoodaConfig.GetString("sooda.cache.type", "inprocess"); switch (cachingPolicy) { case "none": _defaultCachingPolicy = new SoodaNoCachingPolicy(); break; case "all": _defaultCachingPolicy = new SoodaCacheAllPolicy(); break; case "small": _defaultCachingPolicy = new SoodaCacheSmallPolicy(); break; case "smallmedium": _defaultCachingPolicy = new SoodaCacheSmallAndMediumPolicy(); break; default: _defaultCachingPolicy = Activator.CreateInstance(Type.GetType(cachingPolicy, true)) as ISoodaCachingPolicy; break; } switch (cacheType) { case "none": _defaultCache = new SoodaNoCache(); break; case "inprocess": _defaultCache = new SoodaInProcessCache(); break; default: _defaultCache = Activator.CreateInstance(Type.GetType(cacheType, true)) as ISoodaCache; break; } if (_defaultCachingPolicy == null) { _defaultCachingPolicy = new SoodaNoCachingPolicy(); } if (_defaultCache == null) { _defaultCache = new SoodaInProcessCache(); } ISoodaCachingPolicyFixedTimeout sft = _defaultCachingPolicy as ISoodaCachingPolicyFixedTimeout; if (sft != null) { sft.SlidingExpiration = Convert.ToBoolean(SoodaConfig.GetString("sooda.cachingPolicy.slidingExpiration", "true"), CultureInfo.InvariantCulture); sft.ExpirationTimeout = TimeSpan.FromSeconds( Convert.ToInt32(SoodaConfig.GetString("sooda.cachingPolicy.expirationTimeout", "120"), CultureInfo.InvariantCulture)); } logger.Debug("Default cache: {0} Policy: {1}", _defaultCache.GetType().Name, _defaultCachingPolicy.GetType().Name); }
static SoodaCache() { string cachingPolicy = SoodaConfig.GetString("sooda.cachingPolicy", "none"); string cacheType = SoodaConfig.GetString("sooda.cache.type", "inprocess"); switch (cachingPolicy) { case "none": _defaultCachingPolicy = new SoodaNoCachingPolicy(); break; case "all": _defaultCachingPolicy = new SoodaCacheAllPolicy(); break; case "small": _defaultCachingPolicy = new SoodaCacheSmallPolicy(); break; case "smallmedium": _defaultCachingPolicy = new SoodaCacheSmallAndMediumPolicy(); break; default: _defaultCachingPolicy = Activator.CreateInstance(Type.GetType(cachingPolicy, true)) as ISoodaCachingPolicy; break; } switch (cacheType) { case "none": _defaultCache = new SoodaNoCache(); break; case "inprocess": _defaultCache = new SoodaInProcessCache(); break; default: _defaultCache = Activator.CreateInstance(Type.GetType(cacheType, true)) as ISoodaCache; break; } if (_defaultCachingPolicy == null) _defaultCachingPolicy = new SoodaNoCachingPolicy(); if (_defaultCache == null) _defaultCache = new SoodaInProcessCache(); ISoodaCachingPolicyFixedTimeout sft = _defaultCachingPolicy as ISoodaCachingPolicyFixedTimeout; if (sft != null) { sft.SlidingExpiration = Convert.ToBoolean(SoodaConfig.GetString("sooda.cachingPolicy.slidingExpiration", "true"), CultureInfo.InvariantCulture); sft.ExpirationTimeout = TimeSpan.FromSeconds( Convert.ToInt32(SoodaConfig.GetString("sooda.cachingPolicy.expirationTimeout", "120"), CultureInfo.InvariantCulture)); } logger.Debug("Default cache: {0} Policy: {1}", _defaultCache.GetType().Name, _defaultCachingPolicy.GetType().Name); }