SncRedisBundle icon indicating copy to clipboard operation
SncRedisBundle copied to clipboard

Support predis 2.0

Open pesseyjulien opened this issue 3 years ago • 5 comments

Hi,

It seems that upgrading to predis 2.0 is causing trouble.

I got this error when I tried :

! Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#72 !! #message: """ !! Attempted to load class "Factory" from namespace "Predis\Profile".\n !! Did you forget a "use" statement for e.g. "Predis\Command\Factory", "Predis\Connection\Factory", "JsonSchema\Constraints\Factory" or "Doctrine\DBAL\Driver\IBMDB2\Exception\Factory"? !! """ !! #code: 0 !! #file: "./vendor/snc/redis-bundle/src/DependencyInjection/SncRedisExtension.php" !! #line: 170 !! trace: { !! ./vendor/snc/redis-bundle/src/DependencyInjection/SncRedisExtension.php:170 { …} !! ./vendor/snc/redis-bundle/src/DependencyInjection/SncRedisExtension.php:117 { …} !! ./vendor/snc/redis-bundle/src/DependencyInjection/SncRedisExtension.php:68 { …} !! ./vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php:76 { …} !! ./vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php:42 { …} !! ./vendor/symfony/dependency-injection/Compiler/Compiler.php:82 { …} !! ./vendor/symfony/dependency-injection/ContainerBuilder.php:757 { …} !! ./vendor/symfony/http-kernel/Kernel.php:546 { …} !! ./vendor/symfony/http-kernel/Kernel.php:787 { …} !! ./vendor/symfony/http-kernel/Kernel.php:128 { …} !! ./vendor/bref/symfony-bridge/src/BrefKernel.php:62 { …} !! ./vendor/symfony/framework-bundle/Console/Application.php:168 { …} !! ./vendor/symfony/framework-bundle/Console/Application.php:74 { …} !! ./vendor/symfony/console/Application.php:171 { …} !! ./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 { …} !! ./vendor/autoload_runtime.php:35 { …} !! ./bin/console:12 { !! › !! › require_once dirname(DIR).'/vendor/autoload_runtime.php'; !! › !! arguments: { !! "/var/www/html/vendor/autoload_runtime.php" !! } !! } !! } !! } !! 2022-06-08T18:33:11+00:00 [critical] Uncaught Error: Class "Predis\Profile\Factory" not found !!

Best, Julien

pesseyjulien avatar Jun 08 '22 18:06 pesseyjulien

I've released 4.2.0 which declares conflict with predis 2.0 for the time being. I encourage somebody to work on proper support though. I don't use predis myself anymore, so this could otherwise take a while.

ostrolucky avatar Jun 12 '22 11:06 ostrolucky

Try loading the new predis client in SncRedisExtension.php instead of profiles (they were removed in predis 2.0), here is an example

$profileId = sprintf('snc_redis.client.%s_profile', $client['alias']);
$clientDef = new Definition(\Predis\Client::class);
$clientDef->setPublic(false);
$container->setDefinition($profileId, $clientDef);

image

This will break everything if you have a custom configuration in the service container for the predis profiles, but if you were using a default configuration (like me) then this should do the job temporarily until a proper fix is released

macr1408 avatar Jun 16 '22 13:06 macr1408

Hi, thanks for looking into it. I ended up migrating to Phpredis anyway after finding out it's 6x time faster :)

pesseyjulien avatar Jun 20 '22 07:06 pesseyjulien

finding out it's 6x time faster

Interesting, do you have some references to this? Or is it something purely internal? Any further info you could provide about this?

ostrolucky avatar Jun 20 '22 12:06 ostrolucky

The article is from 2019 but seems relevant : https://akalongman.medium.com/phpredis-vs-predis-comparison-on-real-production-data-a819b48cbadb

pesseyjulien avatar Jun 20 '22 14:06 pesseyjulien

I might be interested in implementing support for Predis 2. It looks like it will be required to get rid of deprecation warnings with PHP 8.2.

Any guidelines on what an implementation might look like? Do we want to support both Predis 1 and 2, or would a major version bump to drop Predis 1 be acceptable?

edsrzf avatar Dec 09 '22 01:12 edsrzf

We don't need to support both and major version bump depends on how much configuration changes, but I don't have issues with early major bump to get this support either

ostrolucky avatar Dec 09 '22 10:12 ostrolucky