Exemplo n.º 1
0
        /// <summary>
        /// Updates the specified cache index.
        /// </summary>
        /// <param name="cacheIndex">Index of the cache.</param>
        public static void Update(CacheIndex cacheIndex)
        {
            if (cacheIndex == null)
            {
                throw new ArgumentNullException("cacheIndex");
            }

            string key = CacheIndexMap.GetKey(cacheIndex);

            // if the key exists in the map then replace it with current parameter..
            if (Map.ContainsKey(key))
            {
                CacheIndexMap.Remove(key);
            }

            CacheIndexMap.Add(cacheIndex);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public static CacheIndex Get(string key)
        {
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key", "Requested CacheIndex key is null or empty");
            }

            CacheIndex cacheIndex;

            if (!Map.TryGetValue(key, out cacheIndex))
            {
                cacheIndex = CacheIndex.Create(key);
                CacheIndexMap.Add(cacheIndex);
            }

            return(cacheIndex);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns cache index that matches Uri
        /// </summary>
        /// <param name="uriString">Absolute Uri for resource represented by Uri</param>
        /// <returns></returns>
        public static CacheIndex GetFromUri(string uriString)
        {
            if (String.IsNullOrEmpty(uriString))
            {
                throw new ArgumentNullException("uriString");
            }

            string key = GetKeyFromUri(uriString);

            // To-Do: should this really create a cache index item
            CacheIndex cacheIndex;

            if (!Map.TryGetValue(key, out cacheIndex))
            {
                cacheIndex = CacheIndex.Create(key);
                CacheIndexMap.Add(cacheIndex);
            }

            return(cacheIndex);
        }