Esempio n. 1
0
        internal CachingPolicy GetLocalPolicy(ICacheKey key)
        {
            Guard.NotNull("key", key);
            if (!this.cachingLocalPolicies.ContainsKey(key.GetHashCode()))
            {
                return(null);
            }

            var cachingPolicy = this.cachingLocalPolicies[key.GetHashCode()];

            return(cachingPolicy);
        }
Esempio n. 2
0
        /// <summary>
        /// Determine if an valid entry for the key exists in the staging area.
        /// </summary>
        public bool ContainsKey(ICacheKey key)
        {
            lock (_mapGate)
            {
                Preconditions.CheckNotNull(key);
                EncodedImage storedEncodedImage = default(EncodedImage);
                if (!_map.TryGetValue(key, out storedEncodedImage))
                {
                    return(false);
                }

                if (!EncodedImage.IsValid(storedEncodedImage))
                {
                    // Reference is not valid, this means that someone cleared reference
                    // while it was still in use.
                    // Log error TODO: 3697790
                    _map.Remove(key);
                    Debug.WriteLine($"Found closed reference { storedEncodedImage.GetHashCode() } for key { key.ToString() } ({ key.GetHashCode() })");
                    return(false);
                }

                return(true);
            }
        }