/// <summary> /// Initializes a new instance of the <see cref="CacheCleanup"/> class. /// </summary> public CacheCleanup() { #region Access Log Handler.LogHandler.Tracking( string.Format("Access Method: {0}->{1} ;", this.GetType(), MethodBase.GetCurrentMethod()) ); #endregion Access Log #region retrieve configuration information #region validate configuration entry for cleanup strategy - ServiceCacheCleanUp try { this._cleanupCacheConfiguration = Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.ServiceCacheCleanup; } catch (Exception ex) { const string msg = @"Configuration failure, please validate your [ServiceCacheCleanUp] key, it contains an invalid value!! Current configured value: {0}; As standard the CACHEITEMPRIORITY has been set."; Handler.LogHandler.Fatal(string.Format(msg, Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.ServiceCacheCleanup), ex); this._cleanupCacheConfiguration = Enums.ServiceCacheCleanUp.LRU; } #endregion validate configuration entry for cleanup strategy - ServiceCacheCleanUp #region retrieve configured maximum memory cache size - CacheAmountOfObjects try { this._cacheAmountOfObjects = long.Parse(Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountOfObjects.ToString()) * (1024 * 1024); } catch (Exception ex) { const string msg = @"Configuration failure, please validate your [CacheAmountOfObjects] key, it contains an invalid value!! Current configured value: {0}; standard taken, value:-1. You may explorer now OutOfMemoryExceptions in your log files."; Handler.LogHandler.Fatal(string.Format(msg, Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountOfObjects), ex); } #endregion retrieve configured maximum memory cache size - CacheAmountOfObjects #region retrieve configured fill factor - CacheAmountFillFactorInPercentage try { this.cacheFillFactor = long.Parse(Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountFillFactorInPercentage.ToString()); } catch (Exception ex) { const string msg = @"Configuration failure, please validate your [CacheAmountFillFactorInPercentage] key, it contains an invalid value!! Current configured value: {0}; standard taken, value:90."; Handler.LogHandler.Fatal(string.Format(msg, Provider.Server.IndexusServerReplicationCache.ProviderSection.ServerSetting.CacheAmountFillFactorInPercentage), ex); this.cacheFillFactor = 90; } #endregion retrieve configured fill factor - CacheAmountFillFactorInPercentage #endregion retrieve configuration information }
/// <summary> /// Calculates the hybrid checksum, this is used to /// create rate for every specific object in the cache /// based on various object attributes. /// <remarks> /// The calculate done like this: HybridChecksum((c.HitRatio + ((c.ObjectSize / 1024) + (c.Span.Ticks / 1024) + (c.UsageDatetime.Ticks / 1024)))); /// </remarks> /// </summary> /// <param name="c">an object of type <see cref="Cleanup"/></param> /// <param name="currentConfiguration">The current configuration.</param> /// <returns>a rate as <see cref="long"/></returns> public static long CalculateHybridChecksum(Cleanup c, Enums.ServiceCacheCleanUp currentConfiguration) { #region Access Log #if TRACE { Handler.LogHandler.Tracking("Access Method: " + typeof(CacheCleanup).FullName + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;"); } #endif #endregion Access Log // do not make Hybrid calculations on other cleanup strategy - boost performance if (currentConfiguration == Enums.ServiceCacheCleanUp.HYBRID) { return(HybridChecksum((c.HitRatio + ((c.ObjectSize / 1024) + (c.Span.Ticks / 1024) + (c.UsageDatetime.Ticks / 1024))))); } return(0); }
/// <summary> /// Determines whether the value of an object is valid. /// </summary> /// <param name="value">The object value.</param> public override void Validate(object value) { Enums.ServiceCacheCleanUp t = EnumUtil <Enums.ServiceCacheCleanUp> .Parse(value.ToString()); }