GetEnumerator() public method

public GetEnumerator ( ) : IDictionaryEnumerator
return IDictionaryEnumerator
Example #1
0
        /// <summary>
        /// 清空所有缓存
        /// </summary>
        public static void Clear()
        {
            IDictionaryEnumerator enumerator = objCache.GetEnumerator();

            while (enumerator.MoveNext())
            {
                objCache.Remove(enumerator.Key.ToString());
            }
        }
Example #2
0
        /// <summary>删除所有缓存对象</summary>
        public void DeleteAll()
        {
            IDictionaryEnumerator _enum = __cache.GetEnumerator();

            while (_enum.MoveNext())
            {
                __cache.Remove(_enum.Key.ToString());
            }
        }
Example #3
0
        /// <summary>
        /// 清空Cache
        /// </summary>
        public static void Clear()
        {
            IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();

            while (CacheEnum.MoveNext())
            {
                _cache.Remove(CacheEnum.Key.ToString());
            }
        }
Example #4
0
        /// <summary>
        /// 获取缓存键列表
        /// </summary>
        /// <returns></returns>
        public static List <string> GetKeyList()
        {
            IDictionaryEnumerator CacheEnum  = cache.GetEnumerator();
            List <string>         listResult = new List <string>();

            while (CacheEnum.MoveNext())
            {
                listResult.Add(CacheEnum.Key.ToString());
            }

            return(listResult);
        }
Example #5
0
        /// <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);
            }
        }
Example #6
0
        public static int GetWhere(string key)
        {
            var result = 0;
            IDictionaryEnumerator di = _objCache.GetEnumerator();

            while (di.MoveNext())
            {
                if (di.Key.ToString().IndexOf(key) > -1)
                {
                    result++;
                }
            }
            return(result);
        }
Example #7
0
        /// <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();
        }
Example #8
0
        /// <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);
            }
        }
Example #9
0
        /// <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);
            }
        }
Example #10
0
        /// <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);
            }
        }
Example #11
0
        /// <summary>
        /// from http://www.aspdotnetfaq.com/Faq/How-to-clear-your-ASP-NET-applications-Cache.aspx
        /// </summary>
        public void Purge(string prefix = null)
        {
            List <string> keys = new List <string>();
            // retrieve application Cache enumerator
            IDictionaryEnumerator enumerator = Cache.GetEnumerator();

            // copy all keys that currently exist in Cache
            if (prefix != null)
            {
                while (enumerator.MoveNext())
                {
                    string key = enumerator.Key.ToString();
                    if (key.StartsWith(prefix))
                    {
                        keys.Add(key);
                    }
                }
            }
            else
            {
                keys.Add(enumerator.Key.ToString());
            }
            // delete every key from cache
            foreach (string key in keys)
            {
                Cache.Remove(key);
            }
        }
Example #12
0
        /// <summary>
        /// Searches for the current key in the cache.
        /// </summary>
        /// <param name="cacheKey">The key to search for.</param>
        /// <returns>True if the key exists in the cache else false.</returns>
        public static bool ContainsKey(string cacheKey)
        {
            bool ret = false;

            // Does a cache object exists.
            if (HttpRuntime.Cache != null)
            {
                // Get the cache object and the enumerator
                // from the caching object.
                System.Web.Caching.Cache dataCache = HttpRuntime.Cache;
                IDictionaryEnumerator    keyItem   = dataCache.GetEnumerator();

                // For each key in the cache, if
                // the key is equal to the current
                // key in the cache.
                while (keyItem.MoveNext())
                {
                    if ((keyItem.Key as String) == cacheKey)
                    {
                        ret = true;
                        break;
                    }
                }
            }

            // Return an indicator if the
            // key was found.
            return(ret);
        }
Example #13
0
        /// <summary>
        /// Searches for the current value in the cache.
        /// </summary>
        /// <param name="value">The value to search for.</param>
        /// <returns>True if the value exists in the cache else false.</returns>
        public static bool ContainsValue(object value)
        {
            bool ret = false;

            // Does a cache object exists.
            if (HttpRuntime.Cache != null)
            {
                // Get the cache object and the enumerator
                // from the caching object.
                System.Web.Caching.Cache dataCache = HttpRuntime.Cache;
                IDictionaryEnumerator    valueItem = dataCache.GetEnumerator();

                // For each value in the cache, if
                // the value is equal to the current
                // value in the cache.
                while (valueItem.MoveNext())
                {
                    if (valueItem.Equals(value))
                    {
                        ret = true;
                        break;
                    }
                }
            }

            // Return an indicator if the
            // value was found.
            return(ret);
        }
Example #14
0
 /// <summary>
 /// 清除所有缓存
 /// </summary>
 public override void Clear()
 {
     try
     {
         if (theCache.Count > 0)
         {
             System.Collections.IDictionaryEnumerator e = theCache.GetEnumerator();
             while (e.MoveNext())
             {
                 theCache.Remove(Convert.ToString(e.Key));
             }
         }
         lock (lockObj)
         {
             try
             {
                 theState.Clear();
                 theState = null;
                 theState = new MDictionary <string, CacheDependencyInfo>(500, StringComparer.OrdinalIgnoreCase);
             }
             catch
             {
             }
         }
     }
     catch
     {
         errorCount++;
     }
 }
        /// <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());
            }
        }
Example #16
0
        public void RemoveCache()
        {
            IDictionaryEnumerator CacheEnum = cache.GetEnumerator();

            while (CacheEnum.MoveNext())
            {
                cache.Remove(CacheEnum.Key.ToString());
            }
        }
Example #17
0
 /// <summary>
 /// 清空缓存
 /// </summary>
 public static void CacheClear()
 {
     System.Web.Caching.Cache objCache = HttpRuntime.Cache;
     System.Collections.IDictionaryEnumerator cacheEnumer = objCache.GetEnumerator();
     while (cacheEnumer.MoveNext())
     {
         objCache.Remove(cacheEnumer.Key.ToString());
     }
 }
Example #18
0
        /// <summary>
        /// 清除所有缓存
        /// </summary>
        public void Clear()
        {
            IDictionaryEnumerator em = webCache.GetEnumerator();

            while (em.MoveNext())
            {
                webCache.Remove(em.Key.ToString());
            }
        }
Example #19
0
        /// <summary>
        /// 移除全部缓存
        /// </summary>
        public static void RemoveAll()
        {
            System.Web.Caching.Cache _cache    = HttpRuntime.Cache;
            IDictionaryEnumerator    CacheEnum = _cache.GetEnumerator();

            while (CacheEnum.MoveNext())
            {
                _cache.Remove(CacheEnum.Key.ToString());
            }
        }
        public IList <T> GetAll()
        {
            //TODO:临时方案
            List <string>         cacheKeys = new List <string>();
            IDictionaryEnumerator cacheEnum = cache.GetEnumerator();

            while (cacheEnum.MoveNext())
            {
                cacheKeys.Add(cacheEnum.Key.ToString());
            }

            var      objectKeys = cacheKeys.Where(z => z.StartsWith(CacheSetKey));
            List <T> objects    = new List <T>();

            foreach (var objectKey in objectKeys)
            {
                objects.Add(cache[objectKey] as T);
            }
            return(objects);
        }
Example #21
0
        /// <summary>
        /// 返回缓存键值列表
        /// </summary>
        /// <returns></returns>
        public List <string> GetCacheKeys()
        {
            List <string>         cacheKeys = new List <string>();
            IDictionaryEnumerator cacheEnum = cache.GetEnumerator();

            while (cacheEnum.MoveNext())
            {
                cacheKeys.Add(cacheEnum.Key.ToString());
            }
            return(cacheKeys);
        }
Example #22
0
        protected override List <string> GetAllKeys()
        {
            var keys       = new List <string>();
            var enumerator = _cache.GetEnumerator();

            while (enumerator.MoveNext())
            {
                keys.Add(enumerator.Key.ToString());
            }
            return(keys);
        }
Example #23
0
        /// <summary>
        /// 删除所有缓存
        /// </summary>
        public static void Del()
        {
            IDictionaryEnumerator DicCache = ObjCache.GetEnumerator();
            int count = ObjCache.Count;

            for (int i = 0; i < count; i++)
            {
                DicCache.MoveNext();
                ObjCache.Remove(DicCache.Key.ToString());
            }
        }
Example #24
0
        public static IList <string> GetKeys()
        {
            List <string>         keys       = new List <string>();
            IDictionaryEnumerator enumerator = _cache.GetEnumerator();

            while (enumerator.MoveNext())
            {
                keys.Add(enumerator.Key.ToString());
            }

            return(keys.AsReadOnly());
        }
Example #25
0
 /// <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 static void ClearAllCache()
 {
     System.Web.Caching.Cache c = System.Web.HttpRuntime.Cache;
     if (c != null)
     {
         System.Collections.IDictionaryEnumerator cacheEnumerator = c.GetEnumerator();
         while (cacheEnumerator.MoveNext())
         {
             c.Remove(cacheEnumerator.Key.ToString());
         }
     }
 }
Example #26
0
        public string[] GetKeys()
        {
            var keys = _cache.GetEnumerator();
            var list = new List <string>();

            while (keys.MoveNext())
            {
                list.Add(keys.Key.ToString());
            }

            return(list.ToArray());
        }
Example #27
0
 public override bool RemoveAll()
 {
     if (cache == null)
     {
         return(false);
     }
     else
     {
         IDictionaryEnumerator dicts    = cache.GetEnumerator();
         ArrayList             alRemove = new ArrayList();
         while (dicts.MoveNext())
         {
             alRemove.Add(dicts.Key);
         }
         foreach (string key in alRemove)
         {
             cache.Remove(key);
         }
         return(true);
     }
 }
 public static void Cache_RemoveAll()
 {
     System.Web.Caching.Cache _cache = System.Web.HttpRuntime.Cache;
     System.Collections.IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();
     if (CacheEnum == null)
     {
         return;
     }
     while (CacheEnum.MoveNext())
     {
         System.Web.HttpContext.Current.Cache.Remove(CacheEnum.Key.ToString());
     }
 }
Example #29
0
        /// <summary>
        /// 移除全部缓存
        /// </summary>
        public static void RemoveAll(string key = null)
        {
            key = ConfigHelper.AppSettings(CacheNamePrefix) + key;
            IDictionaryEnumerator CacheEnum = ObjCache.GetEnumerator();

            while (CacheEnum.MoveNext())
            {
                if (key.IsNull() || CacheEnum.Key.ToString().StartsWith(key))
                {
                    Remove(CacheEnum.Key.ToString());
                }
            }
        }
        /// <summary>
        /// 清除所有缓存
        /// </summary>
        public static void Clear()
        {
            //要循环访问 Cache 对象的枚举数
            System.Web.Caching.Cache objCache   = HttpRuntime.Cache;
            IDictionaryEnumerator    enumerator = objCache.GetEnumerator();//检索用于循环访问包含在缓存中的键设置及其值的字典枚举数

            if (enumerator != null)
            {
                while (enumerator.MoveNext())
                {
                    objCache.Remove(enumerator.Key.ToString());
                }
            }
        }