<commit_before>'use strict'

const Trailpack = require('trailpack')

module.exports = class CacheTrailpack extends Trailpack {

  /**
   * Validate caches config
   */
  validate() {
    if (!this.app.config.caches) {
      return Promise.reject(
        new Error('There no cache.js under ./config,' +
          'check it\'s load in ./config/index.js or create it !')
      )
    }
  }

  /**
   * Check if there some stores, if not set a default one
   */
  configure() {
    if (this.app.config.caches.stores.length === 0) {
      this.app.config.caches.stores = [
        // Default Memory Store
        {
          name: 'memory',
          type: 'memory',
          max: 500,
          ttl: 0
        }]

      this.app.config.caches.defaults = ['memory']
    }
  }

  /**
   * create caching stores
   */
  init() {
    return this.app.services.CacheService.init()
  }

  unload() {
    return this.app.services.CacheService.unload()<commit_msg>fix initialize method<commit_after>'use strict'

const Trailpack = require('trailpack')

module.exports = class CacheTrailpack extends Trailpack {

  /**
   * Validate caches config
   */
  validate() {
    if (!this.app.config.caches) {
      return Promise.reject(
        new Error('There no cache.js under ./config,' +
          'check it\'s load in ./config/index.js or create it !')
      )
    }
  }

  /**
   * Check if there some stores, if not set a default one
   */
  configure() {
    if (this.app.config.caches.stores.length === 0) {
      this.app.config.caches.stores = [
        // Default Memory Store
        {
          name: 'memory',
          type: 'memory',
          max: 500,
          ttl: 0
        }]

      this.app.config.caches.defaults = ['memory']
    }
  }

  /**
   * create caching stores
   */
  initialize() {
    return this.app.services.CacheService.init()
  }

  unload() {
    return this.app.services.CacheService.unload()
{'fraction_non_alphanumeric': 0.13660062565172054, 'fraction_numerical': 0.005213764337851929, 'mean_word_length': 1.9937597503900155, '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': '4677636', 'n_tokens_mistral': 623, 'n_tokens_neox': 600, 'n_words': 141}