Esempio n. 1
0
        public override void Remove(string prefix, string key, Guid timestamp)
        {
            string fullName = this.GetFullName(prefix, key);

            DistCache.Remove(fullName);
            cacheKeys.Remove(fullName);
        }
Esempio n. 2
0
        /// <summary>
        /// 根据表名称清除对应的缓存,在添加缓存的时候加上涉及到的表名称
        /// </summary>
        /// <param name="tbName"></param>
        public void RemoveKeyDicByTbName(string tbName)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(tbName))
                {
                    return;
                }
                tbName = tbName.ToLower();
                List <MemcacheKey> MemcacheKeyList = GetMemcacheKeyLis();

                var keyList = MemcacheKeyList.Where(t => t.RelationTableName.ToLower().Contains(tbName)).Select(m => m.Key).ToList();

                MemcacheKeyList.RemoveAll(t => t.RelationTableName.ToLower().Contains(tbName));
                DistCache.Add(KeyDic, MemcacheKeyList);

                keyList = keyList.Distinct().ToList();
                foreach (var item in keyList)
                {
                    DistCache.Remove(item);
                }
            }
            catch
            {
            }
        }
 public static object Remove(string strKey, int cacheType = 1)
 {
     if (cacheType == 0)
     {
         return(DistCache.Remove(strKey));
     }
     else
     {
         return(RedisManager.Remove(strKey));
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 模糊匹配删除缓存
        /// </summary>
        /// <param name="key"></param>
        public void RemoveLikeKey(string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return;
            }
            var MemcacheKeyList = GetMemcacheKeyLis();

            var keyList = MemcacheKeyList.Where(m => m.Key.ToLower().IndexOf(key.ToLower()) >= 0).Select(mm => mm.Key).ToList();

            MemcacheKeyList.RemoveAll(m => keyList.Contains(m.Key));
            DistCache.Add(KeyDic, MemcacheKeyList);

            foreach (var item in keyList)
            {
                DistCache.Remove(item);
            }
        }
Esempio n. 5
0
        public override void Clear(string prefix)
        {
            if (string.IsNullOrWhiteSpace(prefix))
            {
                return;
            }
            IList <string> keys = new List <string>();

            foreach (KeyValuePair <string, string> kvp in cacheKeys)
            {
                if (kvp.Key.Contains(prefix))
                {
                    DistCache.Remove(kvp.Key);
                    keys.Add(kvp.Key);
                }
            }

            foreach (string key in keys)
            {
                cacheKeys.Remove(key);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 批量指定KEY清除缓存
 /// </summary>
 /// <param name="keys"></param>
 public void RemoveKeyDic(string keys)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(keys))
         {
             return;
         }
         List <MemcacheKey> MemcacheKeyList = GetMemcacheKeyLis();
         var keyArray = keys.Split(',').ToList();
         MemcacheKeyList.RemoveAll(m => !string.IsNullOrWhiteSpace(m.Key) && keyArray.Contains(m.Key));
         DistCache.Add(KeyDic, MemcacheKeyList);
         foreach (var key in keyArray)
         {
             if (!string.IsNullOrWhiteSpace(keys))
             {
                 DistCache.Remove(key);
             }
         }
     }
     catch
     {
     }
 }
Esempio n. 7
0
 public static void RemoveKey(string strKey)
 {
     DistCache.Remove(strKey);
 }
Esempio n. 8
0
        public void Remove(string key)
        {
            var a = DistCache.Remove(key);

            RemoveKeyDic(key);
        }
Esempio n. 9
0
 public static object Remove(string key)
 {
     return(DistCache.Remove(key));
 }
Esempio n. 10
0
 /// <summary>
 /// 移除指定键的缓存数据。
 /// </summary>
 /// <param name="key">键。</param>
 public static void Remove(string key)
 {
     _cache.Remove(key);
     DistCache.Remove(key);
 }
Esempio n. 11
0
        public static bool RemoveKey(string strKey)
        {
            object obj = DistCache.Remove(strKey);

            return(Convert.ToBoolean(obj));
        }