def lookup_schema(schema_key)
      lookup_time = Time.now.getutc
      if schema_key.is_a?(String)
        schema_key = SchemaKey.parse_key(schema_key)
      end
      failures = []

      cache_result = @cache[schema_key]
      if not cache_result.nil?
        if not @cacheTtl.nil?
          store_time = cache_result[1]
          time_diff = (lookup_time - store_time).round
          if time_diff >= @cacheTtl
            @cache.delete(schema_key)
            cache_result = nil
          else
            return cache_result[0]
          end
        else
          return cache_result[0]
        end
      end

      if cache_result.nil?          # Fetch from every registry
        for registry in prioritize_repos(schema_key, @registries) do
          begin
            lookup_result = registry.lookup_schema(schema_key)
          rescue StandardError => e
            failures.push(Registries::LookupFailure.new(registry.config.name, e))
          else
            if lookup_result.nil?
              failures.push(Registries::NotFound.new(registry.config.name))
            else
              break
            end
          end
        end

        if lookup_result.nil?
          raise Registries::ResolverError.new(failures, schema_key)
        else
          store_time = Time.now.getutc
          @cache[schema_key] = [lookup_result, store_time]
          lookup_result
        end
      end
    end
def lookup_schema(schema_key)
      lookup_time = Time.now.getutc
      if schema_key.is_a?(String)
        schema_key = SchemaKey.parse_key(schema_key)
      end
      failures = []

      cache_result = @cache[schema_key]
      if not cache_result.nil?
        if not @cacheTtl.nil?
          store_time = cache_result[1]
          time_diff = (lookup_time - store_time).round
          if time_diff >= @cacheTtl
            @cache.delete(schema_key)
            cache_result = nil
          else
            return cache_result[0]
          end
        else
          return cache_result[0]
        end
      end

      if cache_result.nil?          # Fetch from every registry
        for registry in prioritize_repos(schema_key, @registries) do
          begin
            lookup_result = registry.lookup_schema(schema_key)
          rescue StandardError => e
            failures.push(Registries::LookupFailure.new(registry.config.name, e))
          else
            if lookup_result.nil?
              failures.push(Registries::NotFound.new(registry.config.name))
            else
              break
            end
          end
        end

        if lookup_result.nil?
          raise Registries::ResolverError.new(failures, schema_key)
        else
          store_time = Time.now.getutc
          @cache[schema_key] = [lookup_result, store_time]
          lookup_result
        end
      end
    end
Lookup schema in cache or try to fetch