コード例 #1
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);
            }
        }