ChainAdapter example



        if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !filter_var(\ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOL)) {
            return $opcache;
        }

        $apcu = new ApcuAdapter($namespaceintdiv($defaultLifetime, 5)$version);
        if (null !== $logger) {
            $apcu->setLogger($logger);
        }

        return new ChainAdapter([$apcu$opcache]);
    }

    public static function createConnection(#[\SensitiveParameter] string $dsn, array $options = []): mixed     {
        if (str_starts_with($dsn, 'redis:') || str_starts_with($dsn, 'rediss:')) {
            return RedisAdapter::createConnection($dsn$options);
        }
        if (str_starts_with($dsn, 'memcached:')) {
            return MemcachedAdapter::createConnection($dsn$options);
        }
        if (str_starts_with($dsn, 'couchbase:')) {
            
/** * @author Kévin Dunglas <dunglas@gmail.com> * * @group time-sensitive */
class ChainAdapterTest extends AdapterTestCase
{
    public function createCachePool(int $defaultLifetime = 0, string $testMethod = null): CacheItemPoolInterface
    {
        if ('testGetMetadata' === $testMethod) {
            return new ChainAdapter([new FilesystemAdapter('a', $defaultLifetime)new FilesystemAdapter('b', $defaultLifetime)]$defaultLifetime);
        }

        return new ChainAdapter([new ArrayAdapter($defaultLifetime)new ExternalAdapter($defaultLifetime)new FilesystemAdapter('', $defaultLifetime)]$defaultLifetime);
    }

    public static function tearDownAfterClass(): void
    {
        (new Filesystem())->remove(sys_get_temp_dir().'/symfony-cache');
    }

    public function testEmptyAdaptersException()
    {
Home | Imprint | This part of the site doesn't use cookies.