<commit_before><?php
namespace Luxury\Cache;

use Luxury\Constants\Services;
use Luxury\Support\DesignPatterns\Strategy;
use Luxury\Support\Traits\InjectionAwareTrait;
use Phalcon\Cache\BackendInterface;
use Phalcon\Di\InjectionAwareInterface;

/**
 * Class CacheService
 *
 * Provides access to all caches saved through the Strategy Design Pattern
 * and thus easily change the storage algorithm.
 *
 * @package Luxury\Cache
 *
 * @method BackendInterface uses(string $use = null)
 */
class CacheStrategy extends Strategy implements InjectionAwareInterface, BackendInterface
{
    use InjectionAwareTrait;

    protected $default = 'default';

    /**
     * CacheStrategy constructor.
     */
    public function __construct()
    {
        $caches = $this->getDI()->getShared(Services::CONFIG)->cache;

        foreach ($caches as $name => $cache) {
            $this->supported[] = $name;
        }
    }

    /**
     * @inheritdoc
     */
    protected function make($use)
    {
        return $this->getDI()->getShared(Services::CACHE . '.' . $use);
    }

    /**
     * Starts a cache. The keyname allows to identify the created fragment<commit_msg>First configured cache is the default now<commit_after><?php
namespace Luxury\Cache;

use Luxury\Constants\Services;
use Luxury\Support\DesignPatterns\Strategy;
use Luxury\Support\Traits\InjectionAwareTrait;
use Phalcon\Cache\BackendInterface;
use Phalcon\Di\InjectionAwareInterface;

/**
 * Class CacheService
 *
 * Provides access to all caches saved through the Strategy Design Pattern
 * and thus easily change the storage algorithm.
 *
 * @package Luxury\Cache
 *
 * @method BackendInterface uses(string $use = null)
 */
class CacheStrategy extends Strategy implements InjectionAwareInterface, BackendInterface
{
    use InjectionAwareTrait;

    protected $default;

    /**
     * CacheStrategy constructor.
     */
    public function __construct()
    {
        $caches = $this->getDI()->getShared(Services::CONFIG)->cache;

        foreach ($caches as $name => $cache) {
            if (!isset($this->default)) {
                $this->default = $name;
            }

            $this->supported[] = $name;
        }
    }

    /**
     * @inheritdoc
     */
    protected function make($use)
    {
        return $this->getDI()->getShared(Services::CACHE . '.' . $use);
    }

    /**
     * Starts a cache. The keyname allows to identify the created fragment
{'fraction_non_alphanumeric': 0.11403869905310828, 'fraction_numerical': 0.0, 'mean_word_length': 2.9770867430441896, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '3811915', 'n_tokens_mistral': 694, 'n_tokens_neox': 683, 'n_words': 176}