<commit_before>package org.allenai.common.cache

import org.allenai.common.Config._

import com.typesafe.config.Config
import redis.clients.jedis.{ Jedis, JedisPool, JedisPoolConfig, Protocol }
import spray.json._
import scala.collection.JavaConverters._

object JsonQueryCache {
  /** Factory method for creating a cache instance from config.
    * The config must have keys for `hostname` and `clientPrefix`. It may also optionally have
    * keys for `port` and `timeoutMillis`; if not given, these values are set to the Jedis defaults.
    */
  def fromConfig[V](config: Config)(implicit jsonFormat: JsonFormat[V]): JsonQueryCache[V] = {
    // Required fields.
    val hostname: String = config[String]("hostname")
    val clientPrefix: String = config[String]("clientPrefix")

    // Optional overrides for Jedis defaults.
    val port: Int = config.get[Int]("port") getOrElse Protocol.DEFAULT_PORT
    val timeoutMillis: Int = config.get[Int]("timeoutMillis") getOrElse Protocol.DEFAULT_TIMEOUT

    apply[V](hostname, clientPrefix, port, timeoutMillis)
  }

  def apply[V](
    clientPrefix: String,
    hostname: String,
    port: Int = Protocol.DEFAULT_PORT,
    timeoutMillis: Int = Protocol.DEFAULT_TIMEOUT
  )(implicit jsonFormat: JsonFormat[V]): JsonQueryCache[V] = {
    new JsonQueryCache[V](
      clientPrefix,<commit_msg>minor fix.<commit_after>package org.allenai.common.cache

import org.allenai.common.Config._

import com.typesafe.config.Config
import redis.clients.jedis.{ Jedis, JedisPool, JedisPoolConfig, Protocol }
import spray.json._
import scala.collection.JavaConverters._

object JsonQueryCache {
  /** Factory method for creating a cache instance from config.
    * The config must have keys for `hostname` and `clientPrefix`. It may also optionally have
    * keys for `port` and `timeoutMillis`; if not given, these values are set to the Jedis defaults.
    */
  def fromConfig[V](config: Config)(implicit jsonFormat: JsonFormat[V]): JsonQueryCache[V] = {
    // Required fields.
    val hostname: String = config[String]("hostname")
    val clientPrefix: String = config[String]("clientPrefix")

    // Optional overrides for Jedis defaults.
    val port: Int = config.get[Int]("port") getOrElse Protocol.DEFAULT_PORT
    val timeoutMillis: Int = config.get[Int]("timeoutMillis") getOrElse Protocol.DEFAULT_TIMEOUT

    apply[V](clientPrefix, hostname, port, timeoutMillis)
  }

  def apply[V](
    clientPrefix: String,
    hostname: String,
    port: Int = Protocol.DEFAULT_PORT,
    timeoutMillis: Int = Protocol.DEFAULT_TIMEOUT
  )(implicit jsonFormat: JsonFormat[V]): JsonQueryCache[V] = {
    new JsonQueryCache[V](
      clientPrefix,
{'fraction_non_alphanumeric': 0.1057153530070975, 'fraction_numerical': 0.0, 'mean_word_length': 4.3667334669338675, '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': '1218655', 'n_tokens_mistral': 792, 'n_tokens_neox': 795, 'n_words': 226}