class RightApiHelper::Cache
Public Class Methods
new(cache_uuid, cache_tmp_dir=".")
click to toggle source
# File lib/right_api_helper/cache.rb, line 21 def initialize(cache_uuid, cache_tmp_dir=".") logger @cache_file = File.join(cache_tmp_dir, "#{cache_uuid}.yml") end
Public Instance Methods
clear()
click to toggle source
# File lib/right_api_helper/cache.rb, line 43 def clear if File.exists?(@cache_file) @log.info("removing cache file at #{@cache_file}") File.delete(@cache_file) else @log.info("no cache file to remove at #{@cache_file}") end end
get()
click to toggle source
Get all instances for all clouds registered in account
# File lib/right_api_helper/cache.rb, line 27 def get hash = nil if File.exists?(@cache_file) @log.info "Reading cache from #{@cache_file}" hash = YAML::load(File.open(@cache_file)) else @log.info "No cache found at #{@cache_file}" end hash end
set(hash)
click to toggle source
# File lib/right_api_helper/cache.rb, line 38 def set(hash) @log.info "Writing cache to #{@cache_file}" File.open(@cache_file, "w") { |f| f.write(YAML.dump(hash)) } end