class StoreFactory{ public static function createStore(#[\SensitiveParameter] object|string $connection): PersistingStoreInterface
{ switch (true
) { case $connection instanceof \Redis:
case $connection instanceof Relay:
case $connection instanceof \RedisArray:
case $connection instanceof \RedisCluster:
case $connection instanceof \Predis\ClientInterface:
return new RedisStore($connection);
case !\
is_string($connection):
throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".',
$connection::
class));
case str_starts_with($connection, 'redis://'
):
case str_starts_with($connection, 'rediss://'
):
if (!
class_exists(AbstractAdapter::
class)) { throw new InvalidArgumentException('Unsupported Redis DSN. Try running "composer require symfony/cache".'
);
} $connection = AbstractAdapter::
createConnection($connection,
['lazy' => true
]);
return new RedisStore($connection);
}