Method: Kafo::ParserCacheReader#get

Defined in:
lib/kafo/parser_cache_reader.rb

#get(key, manifest_path) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/kafo/parser_cache_reader.rb', line 52

def get(key, manifest_path)
  if @force == false
    logger.debug "Skipping parser cache for #{manifest_path}, forced off"
    return nil
  end

  return nil unless @cache[:files].has_key?(key)

  if @cache[:files][key][:mtime] && File.mtime(manifest_path).to_i > @cache[:files][key][:mtime]
    if @force
      logger.warn "Parser cache for #{manifest_path} is outdated, forced to use it anyway"
    else
      logger.debug "Parser cache for #{manifest_path} is outdated, ignoring cache entry"
      return nil
    end
  end

  @cache[:files][key][:data]
end