Skip to content

Instantly share code, notes, and snippets.

@pfeiferbit
Created June 9, 2016 12:06
Show Gist options
  • Save pfeiferbit/ea0bf7ab3e26010dbddaa1807fa1fc48 to your computer and use it in GitHub Desktop.
Save pfeiferbit/ea0bf7ab3e26010dbddaa1807fa1fc48 to your computer and use it in GitHub Desktop.
Configure TYPO3 6.2 to use Redis as LRU Cache. Put in typo3conf/conf.d/ and include via typo3conf/AdditionalConfiguration.php or merge array with LocalConfiguration.php.
<?php
/**
* @see: typo3_src/typo3/sysext/core/Configuration/DefaultConfiguration.php
*/
/**
* If phpredis extension exists, set cache backends to redis
*/
if (extension_loaded('redis')) {
/**
* Set default lifetime to 0 since Redis eviction policy is set to allkeys-lru
*/
$commonOpts = array(
'defaultLifetime' => 0
);
/**
* Compression is disabled for maximum performance
*/
$redisOpts = array(
'hostname' => '127.0.0.1',
'port' => 6379,
'compression' => false,
'compressionLevel' => 0
);
$opts = array_merge($commonOpts, $redisOpts);
/**
* [BEGIN] cached shared
*/
$sharedCaches = array(
'cache_hash',
'cache_pages',
'cache_pagesection',
'cache_imagesizes',
'cache_rootline'
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_hash'] = array(
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
'backend' => 'TYPO3\CMS\Core\Cache\Backend\RedisBackend',
'options' => array_merge($opts, array(
'database' => 4
))
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pages'] = array(
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
'backend' => 'TYPO3\CMS\Core\Cache\Backend\RedisBackend',
'options' => array_merge($opts, array(
'database' => 5
))
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_pagesection'] = array(
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
'backend' => 'TYPO3\CMS\Core\Cache\Backend\RedisBackend',
'options' => array_merge($opts, array(
'database' => 6
))
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_imagesizes'] = array(
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
'backend' => 'TYPO3\CMS\Core\Cache\Backend\RedisBackend',
'options' => array_merge($opts, array(
'database' => 7
))
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_rootline'] = array(
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
'backend' => 'TYPO3\CMS\Core\Cache\Backend\RedisBackend',
'options' => array_merge($opts, array(
'database' => 8
))
);
/**
* [BEGIN] cached local, no need to share between backends
*/
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['l10n'] = array(
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
'backend' => 'TYPO3\CMS\Core\Cache\Backend\RedisBackend',
'options' => array_merge($opts, array(
'database' => 9
))
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_object'] = array(
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
'backend' => 'TYPO3\CMS\Core\Cache\Backend\RedisBackend',
'options' => array_merge($opts, array(
'database' => 10
))
);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array(
'frontend' => 'TYPO3\CMS\Core\Cache\Frontend\VariableFrontend',
'backend' => 'TYPO3\CMS\Core\Cache\Backend\RedisBackend',
'options' => array_merge($opts, array(
'database' => 11
))
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment