public CustomSessionIdManager() { NCacheSessionStateSettings settings = NCacheSessionStateConfigReader.LoadSessionLocationSettings(); if (settings != null) { foreach (DictionaryEntry entry in settings.PrimaryCache) { this._sid = (string)entry.Key; break; } } }
public RegionalCache(ILogger NCacheLog, NCacheSessionStateSettings setting) { _ncacheLog = NCacheLog; _settings = setting; if (_settings != null) { if (_settings.RecycleInterval != -1) { _connectionRecycler = new System.Timers.Timer(_settings.RecycleInterval * 60 * 1000); _connectionRecycler.AutoReset = true; _connectionRecycler.Elapsed += new System.Timers.ElapsedEventHandler(RecycleCacheConnection); _connectionRecycler.Start(); } } }
public static NCacheSessionStateSettings LoadSessionLocationSettings() { if (_settings == null) { NCacheSection section = null; try { section = new NCacheSection(); } catch (Exception e) { throw new System.Configuration.ConfigurationException("Error reading NCache Section. Exception: " + e.ToString()); } XmlNode ncacheSection = section.NCacheConfigSection; if (ncacheSection != null) { NCacheSessionStateSettings sessionStateSettings = new NCacheSessionStateSettings(); XmlNode sessionLocation = ncacheSection.SelectSingleNode("sessionLocation"); //muds: if (sessionLocation.Attributes["secondary-connection-recycle-interval"] != null) { sessionStateSettings.RecycleInterval = Convert.ToInt32(sessionLocation.Attributes["secondary-connection-recycle-interval"].Value); } if (sessionLocation != null) { XmlNode primaryCache = sessionLocation.SelectSingleNode("primaryCache"); if (primaryCache.Attributes["id"] != null) { string cacheId = primaryCache.Attributes["id"].Value.ToLower(); string sidPrefix = primaryCache.Attributes["sid-prefix"].Value.ToLower(); if (sidPrefix == null || sidPrefix.Length != 4) { throw new System.Configuration.ConfigurationException("Invalid sid-prefix value specified for \"" + cacheId + "\"."); } sessionStateSettings.PrimaryCache.Add(sidPrefix, cacheId); } else { throw new System.Configuration.ConfigurationException("Missing attribute 'id' in primaryCache section."); } XmlNodeList nodeList = sessionLocation.SelectNodes("secondaryCache"); foreach (XmlNode secondaryCache in nodeList) { if (secondaryCache.Attributes["id"] != null) { string cacheId = secondaryCache.Attributes["id"].Value.ToLower(); string sidPrefix = secondaryCache.Attributes["sid-prefix"].Value.ToLower(); if (sidPrefix == null || sidPrefix.Length != 4) { throw new System.Configuration.ConfigurationException("Invalid sid-prefix value specified for \"" + cacheId + "\"."); } if (!sessionStateSettings.SecondaryCaches.Contains(sidPrefix)) { sessionStateSettings.SecondaryCaches.Add(sidPrefix, cacheId); } } else { throw new System.Configuration.ConfigurationException("Missing attribute 'id' in SecondaryCache section."); } } } _settings = sessionStateSettings; } } return(_settings); }
public static NCacheSessionStateSettings LoadSessionLocationSettings() { if (_settings == null) { NCacheSection section = null; try { section = new NCacheSection(); } catch (Exception e) { throw new ConfigurationException("Error reading NCache Section. Exception: "+e.ToString()); } XmlNode ncacheSection = section.NCacheConfigSection; if (ncacheSection != null) { NCacheSessionStateSettings sessionStateSettings = new NCacheSessionStateSettings(); XmlNode sessionLocation = ncacheSection.SelectSingleNode("sessionLocation"); //muds: if (sessionLocation.Attributes["secondary-connection-recycle-interval"] != null) { sessionStateSettings.RecycleInterval = Convert.ToInt32(sessionLocation.Attributes["secondary-connection-recycle-interval"].Value); } if (sessionLocation != null) { XmlNode primaryCache = sessionLocation.SelectSingleNode("primaryCache"); if (primaryCache.Attributes["id"] != null) { string cacheId = primaryCache.Attributes["id"].Value.ToLower(); string sidPrefix = primaryCache.Attributes["sid-prefix"].Value.ToLower(); if (sidPrefix == null || sidPrefix.Length != 4) throw new ConfigurationException("Invalid sid-prefix value specified for \"" + cacheId + "\"."); sessionStateSettings.PrimaryCache.Add(sidPrefix, cacheId); } else { throw new ConfigurationException("Missing attribute 'id' in primaryCache section."); } XmlNodeList nodeList = sessionLocation.SelectNodes("secondaryCache"); foreach (XmlNode secondaryCache in nodeList) { if (secondaryCache.Attributes["id"] != null) { string cacheId = secondaryCache.Attributes["id"].Value.ToLower(); string sidPrefix = secondaryCache.Attributes["sid-prefix"].Value.ToLower(); if (sidPrefix == null || sidPrefix.Length != 4) throw new ConfigurationException("Invalid sid-prefix value specified for \"" + cacheId + "\"."); if (!sessionStateSettings.SecondaryCaches.Contains(sidPrefix)) { sessionStateSettings.SecondaryCaches.Add(sidPrefix, cacheId); } } else { throw new ConfigurationException("Missing attribute 'id' in SecondaryCache section."); } } } _settings = sessionStateSettings; } } return _settings; }