/// <summary> Static constructor initialized this class for use </summary> static AppFabric_Manager() { lastErrorMessage = String.Empty; if (SobekCM_Library_Settings.Caching_Server.Length > 0) { enabled = true; } if (enabled) { if (PrepareClient(SobekCM_Library_Settings.Caching_Server)) { keys = new Expiring_Item_Typed_List<string>(30); } else { lastErrorTime = DateTime.Now; } } }
private static bool Configure( Custom_Tracer Tracer ) { if ( !enabled ) return false; if (( lastErrorTime.HasValue ) && ( DateTime.Now.Subtract( lastErrorTime.Value ).TotalMinutes < 15 )) { if (lastErrorMessage.Length > 0) { Tracer.Add_Trace("AppFabric_Manager.configure", "Network cache temporarily disabled due to previous error ( " + lastErrorTime.Value.ToShortTimeString() + " )<br />" + lastErrorMessage, Custom_Trace_Type_Enum.Error); } else { Tracer.Add_Trace("AppFabric_Manager.configure", "Network cache temporarily disabled due to previous error ( " + lastErrorTime.Value.ToShortTimeString() + " )", Custom_Trace_Type_Enum.Error); } return false; } if ( keys == null ) { if (PrepareClient(SobekCM_Library_Settings.Caching_Server)) { keys = new Expiring_Item_Typed_List<string>(30); return true; } if (lastErrorMessage.Length > 0) { Tracer.Add_Trace("AppFabric_Manager.configure", "Unable to prepare the caching client<br />" + lastErrorMessage, Custom_Trace_Type_Enum.Error); } else { Tracer.Add_Trace("AppFabric_Manager.configure", "Unable to prepare the caching client", Custom_Trace_Type_Enum.Error); } lastErrorTime = DateTime.Now; return false; } bool returnValue = true; try { lastErrorMessage = String.Empty; myDefaultCache.CreateRegion(regionName); } catch (Exception ee ) { lastErrorMessage = ee.Message; returnValue = false; } if (!returnValue) { lastErrorTime = DateTime.Now; keys = null; if (lastErrorMessage.Length > 0) { Tracer.Add_Trace("AppFabric_Manager.configure", "Unable to create the region on the cache server<br />" + lastErrorMessage, Custom_Trace_Type_Enum.Error); } else { Tracer.Add_Trace("AppFabric_Manager.configure", "Unable to create the region on the cache server", Custom_Trace_Type_Enum.Error); } return false; } return true; }