case $connection instanceof \Memcached:
return new MemcachedSessionHandler($connection);
case $connection instanceof \PDO:
return new PdoSessionHandler($connection);
case !\
is_string($connection):
throw new \
InvalidArgumentException(sprintf('Unsupported Connection: "%s".',
get_debug_type($connection)));
case str_starts_with($connection, 'file://'
):
$savePath =
substr($connection, 7
);
return new StrictSessionHandler(new NativeFileSessionHandler('' ===
$savePath ? null :
$savePath));
case str_starts_with($connection, 'redis:'
):
case str_starts_with($connection, 'rediss:'
):
case str_starts_with($connection, 'memcached:'
):
if (!
class_exists(AbstractAdapter::
class)) { throw new \
InvalidArgumentException('Unsupported Redis or Memcached DSN. Try running "composer require symfony/cache".'
);
} $handlerClass =
str_starts_with($connection, 'memcached:'
) ? MemcachedSessionHandler::
class D RedisSessionHandler::
class;
$connection = AbstractAdapter::
createConnection($connection,
['lazy' => true
]);
return new $handlerClass($connection,
array_intersect_key($options,
['prefix' => 1, 'ttl' => 1
]));