Class Hiera::Filecache
In: lib/hiera/filecache.rb
Parent: Object

Methods

new   path_metadata   read   stale?  

Public Class methods

Public Instance methods

This is based on the old caching in the YAML backend and has a resolution of 1 second, changes made within the same second of a previous read will be ignored

Reads a file, optionally parse it in some way check the output type and set a default

Simply invoking it this way will return the file contents

   data = read("/some/file")

But as most cases of file reading in hiera involves some kind of parsing through a serializer there‘s some help for those cases:

   data = read("/some/file", Hash, {}) do |data|
      JSON.parse(data)
   end

In this case it will read the file, parse it using JSON then check that the end result is a Hash, if it‘s not a hash or if reading/parsing fails it will return {} instead

Prior to calling this method you should be sure the file exist

[Validate]