Caching Translations problem

Hello,
I moved my application to Laminas 3 with Php8.1 and now my translation files are not cached anymore.
Also, I get this error message

Fatal error: Uncaught Laminas\ServiceManager\Exception\ServiceNotFoundException: Unable to resolve service “Laminas\Cache\Storage\Adapter\RedisCache” to a factory; are you certain you provided it during configuration? in C:\wamp\www\ecole\vendor\laminas\laminas-servicemanager\src\ServiceManager.php on line 586

Where RedisCache is my Factory intializing my redis server.

Here is my configuration file :

'translator' => [
        'translation_file_patterns' => [
            [
                'base_dir' => __DIR__ . '/../../../data/translations',
                'type' => 'ini',
                'pattern' => '%s.ini',
            ]
        ],
     'cache' => [
            'adapter' => [
                'name'    => 'RedisCache' ,
                'options' => [
                    'persistent_id' => 'nslabs',
                    'server' => [
                        'host' => '127.0.0.1',
                        'port' => 6379,
                    ],
                    /*'cache_dir' => __DIR__ . '/../../../data/cache',
                    'ttl'       => '3600',
                    'namespace'        => 'nslabs',*/                    
                ],
            ],
            'plugins' => [
                [
                    'name'    => 'serializer',
                    'options' => []
                ],
                'exception_handler' => [
                    'throw_exceptions' => true
                ],
                
            ],
        ]

I need to mention that I have created my ‘RedisCache’ factory

Have you installed the related cache adapter? See:

And check if the required factories are installed:

Version 3 of laminas-cache removed support for factories required by this component, so if your application requires laminas-cache version 3 or later, you will also need to install laminas-cache-storage-deprecated-factory

Thank you @froschdesign, it works. But I noticed that when I switch between the languages, translations does not work anymore but in my redis server I see the translation files cached

I solved it by adding this section

'plugins' => [
                [
                    'name'    => 'serializer',
                    'options' => []
                ],
                'exception_handler' => [
                    'throw_exceptions' => true
                ],
                
            ]

One another problem I’m facing is when I deployed my application on Amazon AWS, it works fine. But now after deploying with laminas cache using redis, I get this error shown in the attachment

Any advice or tip to solve it ? My EC2 instance is running a Linux Ubuntu 2023 with php8.1.

I need to say that my application works perfectly on my local machine.

It looks like the server’s version of ext-redis is too new.
You’re going to need to downgrade it.
Something along

apt install php-redis=5.0.2

Should do it.

I am not familiar with EC2, downgrading a php extension might affect other services on the same instance. You know the effects better than me.

Thank you for your response but php-redis is missing in the repo

@ebuddy,

The message in your provided picture suggests that you need to use caret(^) or tilda in your provided configuration of laminas-storage-adapter-redis instead of a constant or you can delete the composer.lock file and run composer install again. I’ve never installed Redis on a server myself. My suggestion is purely based on the message I read. Thanks!

Thanks @ALTAMASH80, I will try and get back to you