Module: Chefdepartie::Cache
Instance Method Summary collapse
Instance Method Details
#cache(path) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chefdepartie/cache.rb', line 18 def cache(path) return false unless cache? hash = File.file?(path) ? CityHash.hash128(File.read(path)) : hashdir(path) hit = @cache[to_key(path)] == hash unless hit @cache[to_key(path)] = hash dump end hit end |
#cache? ⇒ Boolean
29 30 31 |
# File 'lib/chefdepartie/cache.rb', line 29 def cache? !@cache.nil? end |
#flush ⇒ Object
33 34 35 36 |
# File 'lib/chefdepartie/cache.rb', line 33 def flush @cache = {} dump end |
#setup(path) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/chefdepartie/cache.rb', line 10 def setup(path) FileUtils.mkdir_p(File.join(path, 'organizations', 'chef')) @path = File.join(path, 'cache.dat') if File.exist?(@path) then restore else @cache = {} end ds = ChefZero::DataStore::RawFileStore.new(File.join(path)) ChefZero::DataStore::DefaultFacade.new(ds, false, false) end |