<commit_before>module RedisInit
  cattr_accessor :cache_token
  
  def self.redis_uri
    redis_url = ENV["REDISCLOUD_URL"] || ENV["OPENREDIS_URL"] || ENV["REDISGREEN_URL"] || ENV["REDISTOGO_URL"] || ENV["REDIS_URL"]
    return nil unless redis_url
    URI.parse(redis_url)
  end
  
  def self.init
    uri = redis_uri
    return if !uri && ENV['SKIP_VALIDATIONS']
    raise "redis URI needed for resque" unless uri
    if defined?(Resque)
      Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => <PASSWORD>.password)
      Resque.redis.namespace = "coughdrop"
    end
    redis = Redis.new(:host => uri.host, :port => uri.port, :password => <PASSWORD>)
    @default = Redis::Namespace.new("coughdrop-stash", :redis => redis)
    @permissions = Redis::Namespace.new("coughdrop-permissions", :redis => redis)
    self.cache_token = 'abc'
  end
  
  def self.default
    @default
  end
  
  def self.permissions
    @permissions
  end
end

RedisInit.init<commit_msg>namespace queues by environment to prevent server from messing up tests<commit_after>module RedisInit
  cattr_accessor :cache_token
  
  def self.redis_uri
    redis_url = ENV["REDISCLOUD_URL"] || ENV["OPENREDIS_URL"] || ENV["REDISGREEN_URL"] || ENV["REDISTOGO_URL"] || ENV["REDIS_URL"]
    return nil unless redis_url
    URI.parse(redis_url)
  end
  
  def self.init
    uri = redis_uri
    return if !uri && ENV['SKIP_VALIDATIONS']
    raise "redis URI needed for resque" unless uri
    ns_suffix = ""
    if !Rails.env.production?
      ns_suffix = "-#{Rails.env}"
    end
    if defined?(Resque)
      Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => <PASSWORD>)
      Resque.redis.namespace = "coughdrop#{ns_suffix}"
    end
    redis = Redis.new(:host => uri.host, :port => uri.port, :password => <PASSWORD>)
    @default = Redis::Namespace.new("coughdrop-stash#{ns_suffix}", :redis => redis)
    @permissions = Redis::Namespace.new("coughdrop-permissions#{ns_suffix}", :redis => redis)
    self.cache_token = 'abc'
  end
  
  def self.default
    @default
  end
  
  def self.permissions
    @permissions
  end
end

RedisInit.init
{'fraction_non_alphanumeric': 0.1341689879294336, 'fraction_numerical': 0.0, 'mean_word_length': 3.594882729211087, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '1182448', 'n_tokens_mistral': 784, 'n_tokens_neox': 784, 'n_words': 163}