Feature: #104451 - Redis backends support for key prefixing

See forge#104451

Description

It is now possible to add a dedicated key prefix for all invocations of a Redis cache or session backend. This allows to use the same Redis database for multiple caches or even for multiple TYPO3 instances if the provided prefix is unique.

Possible use cases are:

  • Using Redis caching for multiple caches, if only one Redis database is available
  • Pre-fill caches upon deployments using a new prefix (zero downtime deployments)
additional.php example for using Redis as session backend
$GLOBALS['TYPO3_CONF_VARS']['SYS']['session']['BE'] = [
    'backend' => \TYPO3\CMS\Core\Session\Backend\RedisSessionBackend::class,
    'options' => [
        'hostname' => 'redis',
        'database' => '11',
        'compression' => true,
        'keyPrefix' => 'be_sessions_',
    ],
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['session']['FE'] = [
    'backend' => \TYPO3\CMS\Core\Session\Backend\RedisSessionBackend::class,
    'options' => [
        'hostname' => 'redis',
        'database' => '11',
        'compression' => true,
        'keyPrefix' => 'fe_sessions_',
        'has_anonymous' => true,
    ],
];
Copied!
additional.php example for pages cache
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['pages'] = [
    'backend' => \TYPO3\CMS\Core\Cache\Backend\RedisBackend::class,
    'options' => [
        'hostname' => 'redis',
        'database' => 11,
        'compression' => true,
        'keyPrefix' => 'pages_';
    ],
];

$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['rootline'] = [
    'backend' => \TYPO3\CMS\Core\Cache\Backend\RedisBackend::class,
    'options' => [
        'hostname' => 'redis',
        'database' => 11,
        'compression' => true,
        'keyPrefix' => 'rootline_';
    ],
];
Copied!

Impact

The new feature allows to use the same Redis database for multiple caches or even for multiple TYPO3 instances while having no impact on existing configuration.