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)
$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,
],
];
$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_';
],
];
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.
Attention
If you start using the same Redis database for multiple caches or using the same database also for session storage, make sure any involved cache configuration uses a unique key prefix. If only one of the caches does not use a key prefix, any cache flush operation will always flush the whole database, hence also all other caches/sessions.