<commit_before><?php


namespace Vault;

use Cache\Adapter\Common\CacheItem;

class CachedClient extends Client
{
    const READ_CACHE_KEY = 'vault_client_read_cache';

    /**
     * @var bool
     */
    protected $readCacheEnabled = false;

    /**
     * @var int
     */
    protected $readCacheTtl = 3600;

    /**
     * @inheritdoc
     *
     * @throws \Psr\Cache\InvalidArgumentException
     */
    public function read($path)
    {
        if (!$this->readCacheEnabled) {
            return parent::read($path);
        }

        if (!$this->cache) {
            $this->logger->warning('Cache is enabled, but cache pool is not set.');

            return parent::read($path);
        }

        $key = self::READ_CACHE_KEY . str_replace(['{', '}', '(', ')', '/', '\\', '@'], '_', $path);

        if ($this->cache->hasItem($key)) {
            $this->logger->debug('Has read response in cache.', ['path' => $path]);

            return $this->cache->getItem($key)->get();
        }

        $response = parent::read($path);

        $item = (new CacheItem($key))->set($response)->expiresAfter($this->readCacheTtl);

        $this->logger->debug('Saving read response in cache.', ['path' => $path, 'item' => $item]);

        if (!$this->cache->save($item)) {
            $this->logger->warning('Cannot save read response into cache.', ['path' => $path]);
        }

        return $response;
    }

    /**
     * @return bool
     */
    public function isReadCacheEnabled()
    {<commit_msg>replace - _ to in key<commit_after><?php


namespace Vault;

use Cache\Adapter\Common\CacheItem;

class CachedClient extends Client
{
    const READ_CACHE_KEY = 'vault_client_read_cache';

    /**
     * @var bool
     */
    protected $readCacheEnabled = false;

    /**
     * @var int
     */
    protected $readCacheTtl = 3600;

    /**
     * @inheritdoc
     *
     * @throws \Psr\Cache\InvalidArgumentException
     */
    public function read($path)
    {
        if (!$this->readCacheEnabled) {
            return parent::read($path);
        }

        if (!$this->cache) {
            $this->logger->warning('Cache is enabled, but cache pool is not set.');

            return parent::read($path);
        }

        $key = self::READ_CACHE_KEY . str_replace(['{', '}', '(', ')', '/', '\\', '@', '-'], '_', $path);

        if ($this->cache->hasItem($key)) {
            $this->logger->debug('Has read response in cache.', ['path' => $path]);

            return $this->cache->getItem($key)->get();
        }

        $response = parent::read($path);

        $item = (new CacheItem($key))->set($response)->expiresAfter($this->readCacheTtl);

        $this->logger->debug('Saving read response in cache.', ['path' => $path, 'item' => $item]);

        if (!$this->cache->save($item)) {
            $this->logger->warning('Cannot save read response into cache.', ['path' => $path]);
        }

        return $response;
    }

    /**
     * @return bool
     */
    public function isReadCacheEnabled()
    {
{'fraction_non_alphanumeric': 0.18479338842975207, 'fraction_numerical': 0.002644628099173554, 'mean_word_length': 2.202116402116402, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, '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': '7208355', 'n_tokens_mistral': 920, 'n_tokens_neox': 895, 'n_words': 185}