Module: Munin::Cache
- Included in:
- Node
- Defined in:
- lib/munin-ruby/cache.rb
Instance Method Summary collapse
Instance Method Details
#cache(key) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/munin-ruby/cache.rb', line 3 def cache(key) raise RuntimeError, "Block required." unless block_given? data = cache_get(key) if data.nil? data = yield cache_set(key, data) end data end |
#flush_cache ⇒ Object
13 14 15 16 17 18 |
# File 'lib/munin-ruby/cache.rb', line 13 def flush_cache instance_variables.select { |l| l =~ /^@cache_/ }.each do |var| remove_instance_variable(var) end true end |