ConfigurableFilesystemCache example

return $this->namespaceHierarchy = array_keys($namespaceHierarchy);
    }

    /** * @param string[] $queue */
    private function defineCache(array $queue): void
    {
        if ($this->twig->getCache(false) instanceof FilesystemCache) {
            $configHash = md5((string) json_encode($queue, \JSON_THROW_ON_ERROR));

            $fileSystemCache = new ConfigurableFilesystemCache($this->cacheDir);
            $fileSystemCache->setConfigHash($configHash);
            $fileSystemCache->setTemplateScopes($this->templateScopeDetector->getScopes());
            // Set individual twig cache for different configurations             $this->twig->setCache($fileSystemCache);
        }
    }
}
use Shopware\Core\Framework\Adapter\Twig\ConfigurableFilesystemCache;

/** * @internal * * @covers \Shopware\Core\Framework\Adapter\Twig\ConfigurableFilesystemCache */
class ConfigurableFilesystemCacheTest extends TestCase
{
    public function testGenerateKeyChangesHashWithTemplateScope(): void
    {
        $cache = new ConfigurableFilesystemCache('test', 0);

        $withoutScope = $cache->generateKey('foo', 'bar');
        static::assertSame($withoutScope$cache->generateKey('foo', 'bar'));

        $cache->setTemplateScopes(['baz']);
        static::assertNotSame($withoutScope$cache->generateKey('foo', 'bar'));
    }

    public function testGenerateKeyChangesHashWithOptionsHash(): void
    {
        $cache = new ConfigurableFilesystemCache('test', 0);

        
Home | Imprint | This part of the site doesn't use cookies.