Parent

Methods

Class/Module Index [+]

Quicksearch

Moneta::BasicFile

Public Instance Methods

raw_get(key) click to toggle source
# File lib/chef/monkey_patches/moneta.rb, line 40
def raw_get(key)
  if ::File.respond_to?(:binread)
    data = ::File.binread(path(key))
  else
    data = ::File.open(path(key),"rb") { |f| f.read }
  end
  Marshal.load(data)
end
store(key, value, options = {}) click to toggle source
# File lib/chef/monkey_patches/moneta.rb, line 24
def store(key, value, options = {})
  ensure_directory_created(::File.dirname(path(key)))
  ::File.open(path(key), "wb") do |file|
    if @expires
      data = {:value => value}
      if options[:expires_in]
        data[:expires_at] = Time.now + options[:expires_in]
      end
      contents = Marshal.dump(data)
    else
      contents = Marshal.dump(value)
    end
    file.puts(contents)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.