Class: PuppetLibrary::Http::Cache::Disk

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_library/http/cache/disk.rb

Instance Method Summary collapse

Constructor Details

#initialize(directory) ⇒ Disk

Returns a new instance of Disk.



24
25
26
27
# File 'lib/puppet_library/http/cache/disk.rb', line 24

def initialize(directory)
    @directory = directory
    @mutex = Monitor.new
end

Instance Method Details

#clearObject



37
38
39
40
41
# File 'lib/puppet_library/http/cache/disk.rb', line 37

def clear
    @mutex.synchronize do
        FileUtils.rm_rf @directory.path
    end
end

#get(path = "entry") ⇒ Object



29
30
31
32
33
34
35
# File 'lib/puppet_library/http/cache/disk.rb', line 29

def get(path = "entry")
    unless include? path
        buffer = yield
        save(path, buffer)
    end
    retrieve(path)
end