Example #1
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);
        }