<commit_before>package library

import redis.clients.jedis.{JedisPoolConfig, JedisPool}
import play.api.Play.current
import org.apache.commons.pool.impl.GenericObjectPool

/**
 * Redis connection wrapper.
 * You can configure the server details in the application.conf with:
 * <ul>
 * <li>redis.host=localhost</li>
 * <li>redis.port=6379</li>
 * <li>redis.timeout=2000</li>
 * <li>redis.password=<PASSWORD> if required</li>
 * </ul>
 */

object Redis {
  private lazy val host = current.configuration.getString("redis.host").getOrElse("localhost")
  private lazy val port = current.configuration.getInt("redis.port").getOrElse(6379)
  private lazy val timeout = current.configuration.getInt("redis.timeout").getOrElse(30000)
  private lazy val redisPassword = current.configuration.getString("redis.password").getOrElse(null)

  lazy val jedisPoolConfig = {
    var pool = new JedisPoolConfig
    pool.setMaxActive(256)
    pool.setMinIdle(1)
    pool.setMaxWait(10000)
    pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK)
    pool
  }

  lazy val jedisPoolConfig2 = {
    var pool = new JedisPoolConfig
    pool.setMaxActive(64)
    pool.setMinIdle(1)
    pool.setMaxWait(10000)
    pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK)
    pool
  }

  def checkIfConnected(): Unit = {
    play.Logger.info("=== Redis ===")
    play.Logger.info("Checking " + host + ":" + port)
    checkPool(pool, host, port)
  }

  def checkPool(poolCtx: Pool, _host: String, _port: Int) = {
    poolCtx.withClient {
      implicit client =>
        play.Logger.info("Checking\t\t" + _host + ":" + _port + "> " + client.ping())
    }
  }

  lazy val pool = {
    val pool = new Pool(new JedisPool(jedisPoolConfig, host, port, timeout, redisPassword))
    pool
  }

  // when you use a different ExcecutionContext, you have to use a different pool with Redis
  lazy val poolForStats = {
    val pool = new Pool(new JedisPool(jedisPoolConfig2, host, port, timeout, redisPassword))
    pool
  }
}
<commit_msg>feat(redis): Code cleanup, removed useless Pool<commit_after>package library

import redis.clients.jedis.{JedisPoolConfig, JedisPool}
import play.api.Play.current
import org.apache.commons.pool.impl.GenericObjectPool

/**
 * Redis connection wrapper.
 * You can configure the server details in the application.conf with:
 * <ul>
 * <li>redis.host=localhost</li>
 * <li>redis.port=6379</li>
 * <li>redis.timeout=2000</li>
 * <li>redis.password=<PASSWORD> if required</li>
 * </ul>
 */

object Redis {
  private lazy val host = current.configuration.getString("redis.host").getOrElse("localhost")
  private lazy val port = current.configuration.getInt("redis.port").getOrElse(6379)
  private lazy val timeout = current.configuration.getInt("redis.timeout").getOrElse(30000)
  private lazy val redisPassword = current.configuration.getString("redis.password").orNull

  lazy val jedisPoolConfig = {
    var pool = new JedisPoolConfig
    pool.setMaxActive(256)
    pool.setMinIdle(1)
    pool.setMaxWait(10000)
    pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK)
    pool
  }

  def checkIfConnected(): Unit = {
    play.Logger.info("=== Redis ===")
    play.Logger.info("Checking " + host + ":" + port)
    checkPool(pool, host, port)
  }

  def checkPool(poolCtx: Pool, _host: String, _port: Int) = {
    poolCtx.withClient {
      implicit client =>
        play.Logger.info("Checking\t\t" + _host + ":" + _port + "> " + client.ping())
    }
  }

  lazy val pool = {
    val pool = new Pool(new JedisPool(jedisPoolConfig, host, port, timeout, redisPassword))
    pool
  }

}

{'fraction_non_alphanumeric': 0.12869373101353218, 'fraction_numerical': 0.01712234189450428, 'mean_word_length': 3.9821182943603852, 'pattern_counts': {'":': 4, '<': 25, '<?xml version=': 0, '>': 29, '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': '319470', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1219, 'n_words': 249}