<commit_before>require 'faraday'
require 'api_cache'

module FaradayAPICache
  class Middleware < Faraday::Middleware
    def initialize(app, options = {})
      super(app)
      @options = { period: 0, timeout: 0 }.merge(options.to_hash)
    end

    def call(env)
      if env[:method] == :get
        APICache.get(env[:url].to_s, @options) do
          APICache.logger.debug 'FaradayAPICache cache miss... Caching.'
          @app.call(env)
        end
      else
        APICache.logger.debug 'FaradayAPICache cache hit.'
        @app.call(env)
      end
    end

    def self.clear
      self.store = APICache::MemoryStore.new
    end

    def self.logger=(logger)
      APICache.logger = logger
    end

    def self.store=(store)
      APICache.store = store
    end
  end
end<commit_msg>Removed logging, because API cache already does it's own logging<commit_after>require 'faraday'
require 'api_cache'

module FaradayAPICache
  class Middleware < Faraday::Middleware
    def initialize(app, options = {})
      super(app)
      @options = { period: 0, timeout: 0 }.merge(options.to_hash)
    end

    def call(env)
      if env[:method] == :get
        APICache.get(env[:url].to_s, @options) do
          @app.call(env)
        end
      else
        @app.call(env)
      end
    end

    def self.clear
      self.store = APICache::MemoryStore.new
    end

    def self.logger=(logger)
      APICache.logger = logger
    end

    def self.store=(store)
      APICache.store = store
    end
  end
end
{'fraction_non_alphanumeric': 0.10536779324055666, 'fraction_numerical': 0.0026507620941020544, 'mean_word_length': 2.34070796460177, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5545736', 'n_tokens_mistral': 509, 'n_tokens_neox': 489, 'n_words': 119}