IronRuby.Builtins.RubyClass.IsFailureCached C# (CSharp) Method

IsFailureCached() private static method

private static IsFailureCached ( Type type, string methodName, bool isStatic, int extensionVersion ) : bool
type System.Type
methodName string
isStatic bool
extensionVersion int
return bool
        private static bool IsFailureCached(Type/*!*/ type, string/*!*/ methodName, bool isStatic, int extensionVersion) {
            // check for cached lookup failure (if the cache is available):
            bool result = false;
            var key = Key.Create(type, methodName, isStatic);

            var cache = Interlocked.Exchange(ref _clrFailedMemberLookupCache, null);
            if (cache != null) {
                int cachedExtensionVersion;
                if (cache.TryGetValue(key, out cachedExtensionVersion)) {
                    if (cachedExtensionVersion != extensionVersion) {
                        // can't use the cached failure if there are any new extension methods:
                        cache.Remove(key);
                        result = false;
                    } else {
                        result = true;
                    }
                } else {
                    result = false;
                }

                Interlocked.Exchange(ref _clrFailedMemberLookupCache, cache);
            }

#if DEBUG
            PerfTrack.NoteEvent(PerfTrack.Categories.Count, "Ruby: CLR member lookup failure cache " + (result ? "hit" : "miss"));
#endif
            return result;
        }