Issue Bug Closed

#107167Unable to use the default redis database #0 for the session cache

Rémi Payette 07/29/25, 19:46 updated 12/02/25, 13:58

Description

Since #104451 has been implemented, we can use the same redis database for all caches using prefixes.

Since redis doesn’t support databases on multi-core redis server, I was going to use the default database 0 with prefixes for all caches.
https://docs.typo3.org/permalink/t3coreapi:caching-backend-redis-example

It works except for the session cache :
cms-core/Classes/Session/Backend/RedisSessionBackend.php

function validateConfiguration() permits that :

            if ($this->configuration['database'] < 0) {
                throw new \InvalidArgumentException(
                    'The specified database "' . $this->configuration['database'] . '" must be greater or equal than zero.',
                    1481270923
                );
            }

but later,
function initializeConnection()

        if (isset($this->configuration['database'])
            && $this->configuration['database'] > 0
            && !$this->redis->select($this->configuration['database'])
        ) {
            throw new \RuntimeException(
                'The given database "' . $this->configuration['database'] . '" could not be selected.',
                1481270987
            );
        }

is there some logic I didn’t understood or is it a forgotten edge case ? ( > 0 instead of >= 0 )

Reviews 3