# File lib/mcollective/facts/base.rb, line 22
      def get_fact(fact=nil)
        config = Config.instance

        cache_time = config.fact_cache_time || 300

        Thread.exclusive do
          begin
            if (Time.now.to_i - @last_facts_load > cache_time.to_i ) || force_reload?
              Log.debug("Resetting facter cache, now: #{Time.now.to_i} last-known-good: #{@last_facts_load}")

              tfacts = load_facts_from_source

              # Force reset to last known good state on empty facts
              raise "Got empty facts" if tfacts.empty?

              @facts = normalize_facts(tfacts)

              @last_good_facts = @facts.clone
              @last_facts_load = Time.now.to_i
            else
              Log.debug("Using cached facts now: #{Time.now.to_i} last-known-good: #{@last_facts_load}")
            end
          rescue Exception => e
            Log.error("Failed to load facts: #{e.class}: #{e}")

            # Avoid loops where failing fact loads cause huge CPU
            # loops, this way it only retries once every cache_time
            # seconds
            @last_facts_load = Time.now.to_i

            # Revert to last known good state
            @facts = @last_good_facts.clone
          end
        end


        # If you do not supply a specific fact all facts will be returned
        if fact.nil?
          return @facts
        else
          @facts.include?(fact) ? @facts[fact] : nil
        end
      end