/// <summary> /// Get cache container that have underlying cache object(s) /// </summary> /// <param name="settings">output cache settings specified in web.config</param> /// <returns></returns> public static CacheContainer GetCacheInstance(OutputCacheSettings settings) { if (_container == null) { _container = new CacheContainer(settings); } _refCount++; return(_container); }
/// <summary> /// Occurs when ASP.NET application is disposed /// </summary> /// <param name="o"></param> /// <param name="args"></param> private void Dispose(object o, EventArgs args) { try { if (CacheContainer.DisposeCacheInstance()) { if (NCacheLog != null) { NCacheLog.Info("NOutputCache disposed"); } } } catch (Exception e) { RaiseException(e); } }
/// <summary> /// Initializes a module and prepares it to handle requests. /// </summary> /// <param name="application">An <see cref="System.Web.HttpApplication"/> object that provides /// references to the intrinsic server objects (for example, /// Request, Response, Session, and Server) used to service HTTP requests. /// </param> void IHttpModule.Init(HttpApplication application) { if (application == null) { throw new ArgumentNullException("application"); } this._onResolveRequestCache = new EventHandler(ResolveRequestCache); this._onUpdaterequestCache = new EventHandler(UpdateRequestCache); this._onDispose = new EventHandler(Dispose); application.ResolveRequestCache += this._onResolveRequestCache; application.UpdateRequestCache += this._onUpdaterequestCache; application.Disposed += this._onDispose; if (_reader == null) { lock (s_mutex) { if (_reader == null) { NItem.RegisterTypeWithCompactFramework(); _reader = new OutPutCacheConfigReader(); _settings = _reader.LoadCacheSettings(); _reader.LoadPageSettings(); } } } try { if (IsNullOrEmpty(_settings.CacheName)) { return; } if (_settings.EnableLogs || _settings.EnableDetailedLogs) { _ncacheLog = new NCacheLogger(); _ncacheLog.Initialize(LoggerNames.OutputCache, _settings.CacheName); if (_settings.EnableDetailedLogs) { NCacheLog.SetLevel("all"); } else { if (_settings.EnableLogs) { NCacheLog.SetLevel("info"); } } } lock (s_mutex) { this._cache = CacheContainer.GetCacheInstance(_settings); } if (NCacheLog != null) { NCacheLog.Info("NOutputCache initialized"); } } catch (Exception e) { RaiseException(e); } }