public void Put(string key, object value) { Ensure.NotNullOrWhiteSpace(key, "key"); Ensure.NotNull(value, "value"); string cacheKey = GetCacheKey(key); if (cache[cacheKey] != null) { cache.Remove(cacheKey); } if (!rootCacheKeyStored) { StoreRootCacheKey(); } cache.Insert(cacheKey, new DictionaryEntry(key, value), new CacheDependency(null, new[] { rootCacheKey }), System.Web.Caching.Cache.NoAbsoluteExpiration, this.Expiration, this.Priority, null); }
/// <summary> /// 是否存在缓存 /// </summary> /// <param name="key">标识</param> /// <returns></returns> public override bool Contains(string key) { if (theState.ContainsKey(key)) { CacheDependencyInfo info = theState[key]; bool isOutTime = info.createTime.AddMinutes(info.cacheMinutes) < DateTime.Now; if (!isOutTime && theCache[key] != null) { return(true); } else { lock (lockObj) { try { theState.Remove(key); if (isOutTime) { theCache.Remove(key); } } catch { //errorCount++; } } } } return(false); }
/// <summary> /// 清空全部缓存项 /// </summary> public override void Clear() { foreach (string key in Keys) { cache.Remove(key); } }
public List <T> GetList <T>(string keyColl) where T : class { var list = new List <T>(); if (this._cache.Get(keyColl) != null) { var keys = (List <string>)_cache.Get(keyColl); var tmpKeys = new List <string>(); if (!keys.Any()) { return(new List <T>()); } foreach (var item in keys) { tmpKeys.Add(item); var data = (T)_cache.Get(item); if (data != null) { list.Add(data); } } if (tmpKeys.Any()) { var json = Newtonsoft.Json.JsonConvert.SerializeObject(tmpKeys) + ""; _cache.Remove(keyColl); _cache.Insert(keyColl, json); } } return(list); }
/// <summary> /// Remove the object from the storage and clear the Xml assocated with /// the object /// </summary> /// <param name="xpath">hierarchical locatioin of the object</param> public static void Remove(string xpath) { lock (lockHelper) { XmlNode result = objectXmlMap.SelectSingleNode(PrepareXpath(xpath)); //check if the xpath refers to a group(container) or //actual element for cached object if (result.HasChildNodes) { //remove all the cached object in the hastable //and remove all the child nodes XmlNodeList objects = result.SelectNodes("*[@objectId]"); string objectId = ""; foreach (XmlNode node in objects) { objectId = node.Attributes["objectId"].Value; node.ParentNode.RemoveChild(node); //use cache strategy to remove the objects from the //underlying storage // cs.RemoveObject(objectId); webCache.Remove(objectId); } } else { //just remove the element node and the object associate with it string objectId = result.Attributes["objectId"].Value; result.ParentNode.RemoveChild(result); // cs.RemoveObject(objectId); webCache.Remove(objectId); } } }
/// <summary> /// Clear the Cache /// </summary> /// <exception cref="T:NHibernate.Cache.CacheException"></exception> public void Clear() { //remove the root cache item, this will cause all of the individual items to be removed from the cache _webCache.Remove(_rootCacheKey); _isRootItemCached = false; log.Debug("All items cleared from the cache."); }
/// <summary> /// 删除缓存对象 /// </summary> /// <param name="objId">对象的关键字</param> public virtual void RemoveObject(string objId) { if (objId == null || objId.Length == 0) { return; } webCache.Remove(objId); }
public void Remove(string key) { if (string.IsNullOrEmpty(key)) { return; } cache.Remove(key); }
public void Clear() { IDictionaryEnumerator enumerator = cache.GetEnumerator(); while (enumerator.MoveNext()) { cache.Remove(enumerator.Key.ToString()); } }
/// <summary> /// 清空Cache /// </summary> public static void Clear() { IDictionaryEnumerator CacheEnum = _cache.GetEnumerator(); while (CacheEnum.MoveNext()) { _cache.Remove(CacheEnum.Key.ToString()); } }
/// <summary> /// Clears everything in umbraco's runtime cache, which means that not only /// umbraco content is removed, but also other cache items from pages running in /// the same application / website. Use with care :-) /// </summary> public override void ClearAllCache() { var cacheEnumerator = _cache.GetEnumerator(); while (cacheEnumerator.MoveNext()) { _cache.Remove(cacheEnumerator.Key.ToString()); } }
/// <summary> /// 从缓存中删除某一项 /// </summary> /// <param name="key">键值</param> /// <exception cref="System.ArgumentNullException">缓存的key不能为空</exception> public void Remove(string key) { if (string.IsNullOrEmpty(key)) { throw new ArgumentNullException("缓存的key不能为空"); } cache.Remove(key); }
internal void Remove(string cacheId, string key, CacheRemoveOptions options) { Platform.CheckForNullReference(key, "key"); Platform.CheckForNullReference(options, "options"); var cacheKey = GetItemCacheKey(cacheId, options.Region, key); _cache.Remove(cacheKey); }
/// <inheritdoc /> public void Remove(object key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } var cacheKey = GetCacheKey(key); Log.Debug("removing item with key: {0}", cacheKey); _cache.Remove(cacheKey); }
//建立回调委托的一个实例 public void onRemove(string key, object val, CacheItemRemovedReason reason) { try { switch (reason) { case CacheItemRemovedReason.DependencyChanged: { break; } case CacheItemRemovedReason.Expired: { CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(this.onRemove); webCache.Remove(key); webCache.Insert(key, val, null, System.DateTime.Now.AddMinutes(TimeOut), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, callBack); break; } case CacheItemRemovedReason.Removed: { CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(this.onRemove); webCache.Insert(key, val, null, System.DateTime.Now.AddMinutes(TimeOut), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, callBack); break; } case CacheItemRemovedReason.Underused: { CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(this.onRemove); webCache.Insert(key, val, null, System.DateTime.Now.AddMinutes(TimeOut), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, callBack); break; } default: break; } } catch {; } //如需要使用缓存日志,则需要使用下面代码 myLogVisitor.WriteLog(this, key, val, reason); }
public bool DeleteCache(string key) { try { _cache.Remove(key); return(true); } catch (Exception) { return(false); } }
public override bool Remove(string key) { if (cache == null) { return(false); } else { var value = cache.Remove(key); return(true); } }
/// <summary> /// 清除所有缓存 /// </summary> public static void Clear() { IDictionaryEnumerator enumerator = Cache.GetEnumerator(); ArrayList list = new ArrayList(); while (enumerator.MoveNext()) { list.Add(enumerator.Key); } foreach (string str in list) { Cache.Remove(str); } }
/// <summary> /// 清空所有缓存 /// </summary> public static void Clear() { IDictionaryEnumerator enumerator = _cache.GetEnumerator(); List <string> list = new List <string>(); while (enumerator.MoveNext()) { list.Add(enumerator.Key.ToString()); } foreach (string str in list) { _cache.Remove(str); } OnWebCacheClear(); }
public void Flush() { lock (m_SyncObj) { try { foreach (string key in CacheKeys) { cache.Remove(key); } CacheKeys.Clear(); } catch (Exception) { } } }
/// <summary> /// Removes all items from the Cache /// </summary> public static void Clear() { var cacheEnum = Cache.GetEnumerator(); var al = new List <object>(); while (cacheEnum.MoveNext()) { al.Add(cacheEnum.Key); } foreach (string key in al) { Cache.Remove(key); } }
/// <summary> /// 从Cache中移除所有项目 /// </summary> public static void Clear() { IDictionaryEnumerator CacheEnum = _cache.GetEnumerator(); List <object> al = new List <object>(); while (CacheEnum.MoveNext()) { al.Add(CacheEnum.Key); } foreach (string key in al) { _cache.Remove(key); } }
/// <summary> /// 清空所有数据 /// </summary> public static void Clear() { IDictionaryEnumerator cacheEnum = CacheContainer.GetEnumerator(); ArrayList arrayList = new ArrayList(); while (cacheEnum.MoveNext()) { arrayList.Add(cacheEnum.Key); } foreach (string key in arrayList) { CacheContainer.Remove(key); } }
///// <summary> ///// 是否存在cacheKey的缓存项 ///// </summary> //public static bool Contains(string cacheKey) //{ // IDictionaryEnumerator cacheEnum = _cache.GetEnumerator(); // while (cacheEnum.MoveNext()) // { // if (cacheEnum.Key.ToString().Equals(cacheKey, StringComparison.CurrentCultureIgnoreCase)) // return true; // } // return false; //} /// <summary> /// 从缓存中清除所有缓存项 /// </summary> public static void Clear() { IDictionaryEnumerator cacheEnum = _cache.GetEnumerator(); List <string> keys = new List <string>(); while (cacheEnum.MoveNext()) { keys.Add(cacheEnum.Key.ToString()); } foreach (string key in keys) { _cache.Remove(key); } }
/// <summary> /// 更新 /// </summary> /// <param name="userInfo">用户</param> /// <param name="entity">实体</param> /// <param name="statusCode">状态码</param> /// <param name="statusMessage">状态信息</param> /// <returns>影响行数</returns> public int Update(BaseUserInfo userInfo, BaseAreaEntity entity, out string statusCode, out string statusMessage) { int result = 0; string returnCode = string.Empty; string returnMessage = string.Empty; var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) => { var manager = new BaseAreaManager(dbHelper, userInfo); result = manager.Update(entity, out returnCode); returnMessage = manager.GetStateMessage(returnCode); }); statusCode = returnCode; statusMessage = returnMessage; // 处理缓存优化性能 System.Web.Caching.Cache cache = HttpRuntime.Cache; string cacheObject = string.Empty; if (string.IsNullOrEmpty(entity.ParentId)) { cacheObject = "AreaProvince"; } else { cacheObject = "Area" + entity.ParentId; } cache.Remove(cacheObject); return(result); }
public static void ClearCachedTemplate(int templateID) { if (templateCache["template" + templateID.ToString()] != null) { templateCache.Remove("template" + templateID.ToString()); } }
/// <summary> /// 删除缓存 /// </summary> /// <param name="cacheKey">缓存键值</param> public void RemoveCache(string cacheKey) { if (!string.IsNullOrEmpty(cacheKey)) { cache.Remove(cacheKey); } }
public void Delete(string cache_key) { if (Exists(cache_key)) { cache.Remove(cache_key); } }
private void LocalClearItem(string key) { if (!String.IsNullOrWhiteSpace(key)) { _Cache.Remove(key); } }
public void InvalidateCacheItem(string cacheKey) { if (_cache.Get(cacheKey) != null) { _cache.Remove(cacheKey); } }
public static void ClearCache(Cache cache) { var itms = GetAllUsers(cache); foreach (var itm in itms) { var email = itm.Value["email"].ReadAs<string>(); cache.Remove(email); } }
public static void Flush(string name, Cache cache) { var cacheKey = CACHE_PREFIX + name; cache.Remove(cacheKey); }
public void RemoveCache(Cache cache, string cacheKey, int? tenantId = null) { string key = GetTenantCacheKey(cacheKey, tenantId); if (cache[key] != null) { cache.Remove(key); } }
public static void Flush(string feedUri, Cache cache) { var cacheKey = CACHE_PREFIX + feedUri; cache.Remove(cacheKey); }