<commit_before><?php

namespace M6Web\Bundle\RedisBundle\GuzzleHttp;

use M6Web\Bundle\RedisBundle\Redis\Redis;
use Doctrine\Common\Cache\Cache;

/**
 * Redis cache adapter
 *
 */
class RedisCacheAdapter implements Cache
{
    /**
     * @var interge
     */
    protected $defaultTtl = null;

    /**
     * @var boolean
     */
    protected $forceTtl = false;

    /**
     * @var \M6Web\Bundle\RedisBundle\Redis\Redis
     */
    protected $cache = null;

    /**
     * RedisCacheAdapter
     *
     * @param \M6Web\Bundle\RedisBundle\Redis\Redis $redis
     * @param null|int                              $defaultTtl
     * @param boolean                               $forceTtl
     *
     * @internal param \Guzzle\Cache $cache Redis cache object
     */
    public function __construct(Redis $redis, $defaultTtl = null, $forceTtl = false)
    {
        $this->cache = $redis;

        if ($defaultTtl) {
            $this->defaultTtl = $defaultTtl;
        }

        if ($forceTtl) {
            $this->forceTtl = $forceTtl;
        }
    }

    /**
     * {@inheritdoc}
     */
    public function contains($id, array $options = null)
    {
        return $this->cache->has($id);
    }

    /**
     * {@inheritdoc}
     */
    public function delete($id, array $options = null)
    {
        return $this->cache->remove($id);
    }

    /**
     * {@inheritdoc}
     */
    public function fetch($id, array $options = null)
    {
        return unserialize($this->cache->get($id));
    }

    /**
     * {@inheritdoc}
     */
    public function save($id, $data, $lifeTime = false, array $options = null)
    {
        if ($this->forceTtl or (is_int($lifeTime) && $lifeTime < 0) or (!$lifeTime)) {
            $lifeTime = $this->defaultTtl;
        }

        return $this->cache->set($id, serialize($data), $lifeTime);
    }

    /**
     * {@inheritdoc}
     */<commit_msg>Update save method guzzle adapter<commit_after><?php

namespace M6Web\Bundle\RedisBundle\GuzzleHttp;

use M6Web\Bundle\RedisBundle\Redis\Redis;
use Doctrine\Common\Cache\Cache;

/**
 * Redis cache adapter
 *
 */
class RedisCacheAdapter implements Cache
{
    /**
     * @var interge
     */
    protected $defaultTtl = null;

    /**
     * @var boolean
     */
    protected $forceTtl = false;

    /**
     * @var \M6Web\Bundle\RedisBundle\Redis\Redis
     */
    protected $cache = null;

    /**
     * RedisCacheAdapter
     *
     * @param \M6Web\Bundle\RedisBundle\Redis\Redis $redis
     * @param null|int                              $defaultTtl
     * @param boolean                               $forceTtl
     *
     * @internal param \Guzzle\Cache $cache Redis cache object
     */
    public function __construct(Redis $redis, $defaultTtl = null, $forceTtl = false)
    {
        $this->cache = $redis;

        if ($defaultTtl) {
            $this->defaultTtl = $defaultTtl;
        }

        if ($forceTtl) {
            $this->forceTtl = $forceTtl;
        }
    }

    /**
     * {@inheritdoc}
     */
    public function contains($id, array $options = null)
    {
        return $this->cache->has($id);
    }

    /**
     * {@inheritdoc}
     */
    public function delete($id, array $options = null)
    {
        return $this->cache->remove($id);
    }

    /**
     * {@inheritdoc}
     */
    public function fetch($id, array $options = null)
    {
        return unserialize($this->cache->get($id));
    }

    /**
     * {@inheritdoc}
     */
    public function save($id, $data, $lifeTime = false)
    {
        if ($this->forceTtl or (is_int($lifeTime) && $lifeTime < 0) or (!$lifeTime)) {
            $lifeTime = $this->defaultTtl;
        }

        return $this->cache->set($id, serialize($data), $lifeTime);
    }

    /**
     * {@inheritdoc}
     */
{'fraction_non_alphanumeric': 0.14770617873243172, 'fraction_numerical': 0.0026518164942985947, 'mean_word_length': 1.8212415856394915, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, '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': '4739003', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1205, 'n_words': 233}