<commit_before>require 'cache_for'
require 'time'
require 'redis'
require 'uri'

module CacheFor

  class Base
    attr_accessor :for_seconds
    attr_accessor :redis_store

    DefaultSeconds = 600 # 10 minutes
    DefaultUri = URI::parse("redis://localhost:6379")
    CacheMiss = nil

    def initialize(redis_uri = nil, default_seconds: Base::DefaultSeconds)
      redis_uri = to_uri(redis_uri)
      redis_store = Redis.new( host: redis_uri.host, port: redis_uri.port )
      database = redis_uri.path[1..-1] || '0'
      redis_store.select database rescue nil
      @redis_store, @for_seconds = redis_store, default_seconds
    end

    def to_uri(obj = DefaultUri)<commit_msg>cache_for uses redis-rb URL to initialize<commit_after>require 'cache_for'
require 'time'
require 'redis'
require 'uri'

module CacheFor

  class Base
    attr_accessor :for_seconds
    attr_accessor :redis_store

    DefaultSeconds = 600 # 10 minutes
    DefaultUri = URI::parse("redis://localhost:6379")
    CacheMiss = nil

    def initialize(redis_uri = nil, default_seconds: Base::DefaultSeconds)
      @for_seconds = default_seconds
      @redis_store = Redis.new url: redis_uri
    end

    def to_uri(obj = DefaultUri)
{'fraction_non_alphanumeric': 0.09105960264900662, 'fraction_numerical': 0.0173841059602649, 'mean_word_length': 3.855421686746988, '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': '6500143', 'n_tokens_mistral': 415, 'n_tokens_neox': 391, 'n_words': 95}