<commit_before>// @flow
// $FlowFixMe
const redis = require('redis')

import type { callback } from '../constants/flow-types'


class RedisCache {
  client: any
  prefix: string

  constructor(opts: {
    host: string,
    port: number,
    keyPrefix: string
  }) {
    const options = Object.assign({}, opts || {}, {
      host: '127.0.0.1',
      port: 6379,
      keyPrefix: 'kindredAPI-'
    })

    this.client = redis.createClient(options.port, options.host)
    this.client.on('error', function (err) {
      console.log('Redis error:', err)
    })

    this.prefix = options.keyPrefix
  }

  get(args: { key: string }, cb: callback): void {
    this.client.get(this.prefix + args.key, (err, reply) => {
      reply ? cb(err, reply) : cb(err)
      return
    })<commit_msg>Fix (#22) : Redis config could not be set in the options (#23)<commit_after>// @flow
// $FlowFixMe
const redis = require('redis')

import type { callback } from '../constants/flow-types'


class RedisCache {
  client: any
  prefix: string

  constructor(opts: {
    host: string,
    port: number,
    keyPrefix: string
  }) {
    const options = Object.assign({
      host: '127.0.0.1',
      port: 6379,
      keyPrefix: 'kindredAPI-'
    }, opts || {})

    this.client = redis.createClient(options.port, options.host)
    this.client.on('error', function (err) {
      console.log('Redis error:', err)
    })

    this.prefix = options.keyPrefix
  }

  get(args: { key: string }, cb: callback): void {
    this.client.get(this.prefix + args.key, (err, reply) => {
      reply ? cb(err, reply) : cb(err)
      return
    })
{'fraction_non_alphanumeric': 0.15930304915992533, 'fraction_numerical': 0.014934660858743, 'mean_word_length': 2.688073394495413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1518484', 'n_tokens_mistral': 562, 'n_tokens_neox': 537, 'n_words': 131}