<commit_before><?php

namespace Nip\Database\Metadata;

class Cache extends \Nip\Cache\Manager
{

    protected $_ttl = 10*24*60*60;
    protected $_active = true;
    protected $_metadata;

    public function describeTable($table)
    {
        return $this->get($table);
    }

    public function reload($cacheId)
    {
        return $this->saveData($cacheId, $this->generate($cacheId));
    }

    public function generate($cacheId)
    {
        $data = $this->getMetadata()->getConnection()->describeTable($cacheId);
        $this->_data[$cacheId] = $data;
        return $data;
    }

    public function get($cacheId)
    {
        if (!$this->valid($cacheId)) {
            $this->reload($cacheId);
        }

        return $this->getData($cacheId);
    }

    public function cachePath()
    {
        return parent::cachePath() . '/db-metadata/';
    }

    public function setMetadata($metadata)
    {
        $this->_metadata = $metadata;
        return $this;
    }

    /**
     * @return Data
     */
    public function getMetadata()
    {
        return $this->_metadata;
    }

}<commit_msg>update db cache to include database in filename<commit_after><?php

namespace Nip\Database\Metadata;

use Nip\Cache\Manager as CacheManager;
use Nip\Database\Connection;

class Cache extends CacheManager
{

    protected $_ttl = 10 * 24 * 60 * 60;
    protected $_active = true;
    protected $_metadata;

    public function describeTable($table)
    {
        $cacheId = $this->getCacheId($table);

        return $this->get($cacheId);
    }

    public function getCacheId($table)
    {
        return $this->getConnection()->getDatabase().'.'.$table;
    }

    /**
     * @return Connection
     */
    public function getConnection()
    {
        return $this->getMetadata()->getConnection();
    }

    /**
     * @return Manager
     */
    public function getMetadata()
    {
        return $this->_metadata;
    }

    public function setMetadata($metadata)
    {
        $this->_metadata = $metadata;

        return $this;
    }

    public function get($cacheId)
    {
        if (!$this->valid($cacheId)) {
            $this->reload($cacheId);
        }

        return $this->getData($cacheId);
    }

    public function reload($cacheId)
    {
        return $this->saveData($cacheId, $this->generate($cacheId));
    }

    public function generate($cacheId)
    {
        $data = $this->getConnection()->describeTable($cacheId);
        $this->_data[$cacheId] = $data;

        return $data;
    }

    public function cachePath()
    {
        return parent::cachePath().'/db-metadata/';
    }

}
{'fraction_non_alphanumeric': 0.1415525114155251, 'fraction_numerical': 0.0060882800608828, 'mean_word_length': 2.2780548628428927, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '3287331', 'n_tokens_mistral': 794, 'n_tokens_neox': 757, 'n_words': 155}