<commit_before>package cms

import play.api.Application
import play.api.Play.current
import com.mongodb.casbah.Imports._
import com.novus.salat._
import com.novus.salat.global._
import cms.dto.Entry
import play.api.cache.Cached
import play.api.cache.Cache
import cms.dto.EntryType

object ContentManager {

  val defaultLanguage = "en"
  // in seconds
  val defaultTTL = 1000

  import play.api.Play.current
  import com.mongodb.casbah.Imports._
  import com.mongodb.casbah.MongoURI

  private val fullParsingRegex = """mongodb://(.+)[:](.+)[@](.+)[:](\d+)[/](.+)""".r
  private val simpleParsingRegex = """mongodb://(.+)[/](.+)""".r

  lazy val mongoDB = {
    val mongoUri = current.configuration.getString("mongodb.uri").getOrElse {
      throw new RuntimeException("mongodb.uri could not be resolved")
    }
    mongoUri match {
      case fullParsingRegex(username, password, server, port, database) => {
        val db = MongoConnection(MongoURI(mongoUri))(database)
        db.authenticate(username, password)
        db
      }
      case simpleParsingRegex(server, database) => MongoConnection(MongoURI(mongoUri))(database)
      case _ => throw new RuntimeException("Not able to parse mongodb.uri")
    }
  }

  private lazy val entries = mongoDB("entries")

  def cache[A](key: String)(f: => A): A = {
    val fullKey = "entries_" + key
    
    if (key == "all") {
      println(Cache.get(fullKey))
    }

    Cache.get(fullKey) match {
      case Some(e: A) if e != None => {
        e
      }
      case _ => {<commit_msg>Update app/cms/ContentManager.scala<commit_after>package cms

import play.api.Application
import play.api.Play.current
import com.mongodb.casbah.Imports._
import com.novus.salat._
import com.novus.salat.global._
import cms.dto.Entry
import play.api.cache.Cached
import play.api.cache.Cache
import cms.dto.EntryType

object ContentManager {

  val defaultLanguage = "en"
  // in seconds
  val defaultTTL = 1000

  import play.api.Play.current
  import com.mongodb.casbah.Imports._
  import com.mongodb.casbah.MongoURI

  private val fullParsingRegex = """mongodb://(.+)[:](.+)[@](.+)[:](\d+)[/](.+)""".r
  private val simpleParsingRegex = """mongodb://(.+)[/](.+)""".r

  lazy val mongoDB = {
    val mongoUri = current.configuration.getString("mongodb.uri").getOrElse {
      throw new RuntimeException("mongodb.uri could not be resolved")
    }
    mongoUri match {
      case fullParsingRegex(username, password, server, port, database) => {
        val db = MongoConnection(MongoURI(mongoUri))(database)
        db.authenticate(username, password)
        db
      }
      case simpleParsingRegex(server, database) => MongoConnection(MongoURI(mongoUri))(database)
      case _ => throw new RuntimeException("Not able to parse mongodb.uri")
    }
  }

  private lazy val entries = mongoDB("entries")

  def cache[A](key: String)(f: => A): A = {
    val fullKey = "entries_" + key

    Cache.get(fullKey) match {
      case Some(e: A) if e != None => {
        e
      }
      case _ => {
{'fraction_non_alphanumeric': 0.1434710743801653, 'fraction_numerical': 0.002644628099173554, 'mean_word_length': 3.2619718309859156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2333342', 'n_tokens_mistral': 1044, 'n_tokens_neox': 982, 'n_words': 219}