<commit_before>module Munin
  module Cache
    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
    
    def flush_cache
      instance_variables.select { |l| l =~ /^@cache_/ }.each do |var|
        remove_instance_variable(var)
      end
      true
    end
    
    protected
    
    def cache_key(key)
      "@cache_#{key.gsub('.','__')}".to_sym
    end
      
    def cache_get(key)
      instance_variable_get(cache_key(key))
    end
    
    def cache_set(key, value)
      instance_variable_set(cache_key(key), value)
    end
  end
end<commit_msg>Solved a bug that prevented nodes with a '-' in the name to be used<commit_after>module Munin
  module Cache
    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
    
    def flush_cache
      instance_variables.select { |l| l =~ /^@cache_/ }.each do |var|
        remove_instance_variable(var)
      end
      true
    end
    
    protected
    
    def cache_key(key)
      "@cache_#{key.gsub(/[\.-]/,'__')}".to_sym
    end
      
    def cache_get(key)
      instance_variable_get(cache_key(key))
    end
    
    def cache_set(key, value)
      instance_variable_set(cache_key(key), value)
    end
  end
end
{'fraction_non_alphanumeric': 0.09539918809201624, 'fraction_numerical': 0.0, 'mean_word_length': 2.08125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4517907', 'n_tokens_mistral': 492, 'n_tokens_neox': 493, 'n_words': 118}