public async Task ClearCacheMaxAgeTest() { //Clear the cache await DataCache.ClearAll(); await DataCache.Set("first", "first result"); await DataCache.Set("second", "second result"); await DataCache.Clear(TimeSpan.FromHours(1)); //Nothing is gone var firstResult = await DataCache.GetFromCache <string>("first"); Assert.IsNotNull(firstResult); //Second is still available var secondResult = await DataCache.GetFromCache <string>("second"); Assert.AreEqual("second result", secondResult); //Clear everything until now await DataCache.Clear(TimeSpan.FromSeconds(0)); //Everything should be gone firstResult = await DataCache.GetFromCache <string>("first"); Assert.IsNull(firstResult); secondResult = await DataCache.GetFromCache <string>("second"); Assert.IsNull(secondResult); }
protected void Page_Load(object sender, EventArgs e) { Master.Title = "缓存管理"; string act = Utils.GetRequest("act", "all", 1, "", ""); if (act == "del") { DataCache.Clear(); Utils.Success("清空缓存", "清空缓存,正在返回..", Utils.getUrl("cache.aspx"), "1"); } else { //System.Web.Caching.Cache objCache = HttpRuntime.Cache; //IDictionaryEnumerator CacheEnum = objCache.GetEnumerator(); //while (CacheEnum.MoveNext()) //builder.Append(CacheEnum.Key.ToString()+":"+CacheEnum.Value.ToString() + "<br />"); builder.Append(Out.Div("title", "缓存管理")); builder.Append(Out.Tab("<div>", "<br />")); builder.Append("<a href=\"" + Utils.getUrl("cache.aspx?act=del") + "\">清空系统缓存</a>"); builder.Append(Out.Tab("</div>", "")); builder.Append(Out.Tab("<div class=\"hr\"></div>", Out.Hr())); builder.Append(Out.Tab("<div>", "")); builder.Append("<a href=\"" + Utils.getUrl("default.aspx") + "\">系统服务中心</a><br />"); builder.Append(Out.Tab("</div><div class=\"title\"><a href=\"" + Utils.getUrl("../default.aspx") + "\">返回管理中心</a>", "<a href=\"" + Utils.getUrl("../default.aspx") + "\">返回管理中心</a>")); builder.Append(Out.Tab("</div>", "<br />")); } }
public ActionResult ClearCacheContents(string key) { if (key != _config.Get <string>("CacheViewKey")) { return(new HttpNotFoundResult()); } _cache.Clear(); return(Content("CLEARED CACHE")); }
public void FlushAll() { _logger.Debug("Flushing cache"); try { _cache.Clear(); } catch (Exception cacheException) { _logger.Warn("Attempt to clear cache failed", cacheException); return; } _logger.Debug("Flushed cache"); }
/// <summary> /// Clears all cache entries from all domains. /// </summary> public void Clear() { if (!Enabled) { return; } try { Cache.Clear(); } catch (DataCacheException ex) { if (IsRegionNotFoundException(ex)) { return; } throw; } }
public async Task ClearCacheMaxSizeTest() { //Clear the cache await DataCache.ClearAll(); await DataCache.Set("first", "first result"); await DataCache.Set("second", "second result"); await DataCache.Clear(100); //First is gone var firstResult = await DataCache.GetFromCache <string>("first"); Assert.IsNull(firstResult); //Second is still available var secondResult = await DataCache.GetFromCache <string>("second"); Assert.AreEqual("second result", secondResult); }
public void Dispose(ComputerStateType state) { if (IsDisposed) { return; } _timerManager.Dispose(); ApplyComputerStateProfile(state); _temperatureManager.Dispose(); _sensorManager.Dispose(); _deviceManager.Dispose(); _effectManager.Dispose(); _speedControllerManager.Dispose(); _configManager.Dispose(); _cache.Clear(); Dispose(); IsDisposed = true; }
public void Finalize(ComputerStateType state = ComputerStateType.Shutdown) { if (IsDisposed) { return; } Logger.Info($"{new string('=', 64)}"); Logger.Info("Finalizing..."); _timerManager?.Dispose(); if (_deviceManager != null) { ApplyComputerStateProfile(state); } _sensorManager?.Dispose(); _deviceManager?.Dispose(); _effectManager?.Dispose(); _speedControllerManager?.Dispose(); _configManager?.Dispose(); _cache?.Clear(); _timerManager = null; _deviceManager = null; _sensorManager = null; _deviceManager = null; _effectManager = null; _speedControllerManager = null; _configManager = null; _cache = null; Dispose(); IsDisposed = true; Logger.Info("Finalizing done!"); Logger.Info($"{new string('=', 64)}"); }
public void Clear() { _versions = null; _cache.Clear(); }
public override void ClearAll() { _dataChache.Clear(); }