Skip to content

Instantly share code, notes, and snippets.

@vladdancer
Last active February 25, 2021 10:51
Show Gist options
  • Save vladdancer/58d1a715cfe39742ff4238dfa690595b to your computer and use it in GitHub Desktop.
Save vladdancer/58d1a715cfe39742ff4238dfa690595b to your computer and use it in GitHub Desktop.
Redis config for settings.php #drupal8 #redis
{
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "",
"role": ""
}
],
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"drupal/redis": "^1.4"
}
}
<?php
if (extension_loaded('redis')) {
$settings['redis.connection']['host'] = 'redis';
$settings['redis.connection']['port'] = '6379';
//$settings['redis.connection']['password'] = '';
$settings['redis.connection']['base'] = 0;
$settings['redis.connection']['interface'] = 'PhpRedis';
$settings['container_yamls'][] = 'modules/contrib/redis/example.services.yml';
$settings['container_yamls'][] = 'modules/contrib/redis/redis.services.yml';
//$class_loader = require '../../../vendor/autoload.php';
$class_loader->addPsr4('Drupal\\redis\\', 'modules/contrib/redis/src');
$settings['bootstrap_container_definition'] = [
'parameters' => [],
'services' => [
'redis.factory' => [
'class' => 'Drupal\redis\ClientFactory',
],
'cache.backend.redis' => [
'class' => 'Drupal\redis\Cache\CacheBackendFactory',
'arguments' => ['@redis.factory', '@cache_tags_provider.container', '@serialization.phpserialize'],
],
'cache.container' => [
'class' => '\Drupal\redis\Cache\PhpRedis',
'factory' => ['@cache.backend.redis', 'get'],
'arguments' => ['container'],
],
'cache_tags_provider.container' => [
'class' => 'Drupal\redis\Cache\RedisCacheTagsChecksum',
'arguments' => ['@redis.factory'],
],
'serialization.phpserialize' => [
'class' => 'Drupal\Component\Serialization\PhpSerialize',
],
],
];
$settings['cache']['default'] = 'cache.backend.redis';
$settings['cache']['bins']['bootstrap'] = 'cache.backend.chainedfast';
$settings['cache']['bins']['discovery'] = 'cache.backend.chainedfast';
$settings['cache']['bins']['config'] = 'cache.backend.chainedfast';
$conf['cache_class_cache'] = 'Redis_Cache';
}
$config['file.settings']['make_unused_managed_files_temporary'] = TRUE;
$config['file.settings']['temporary_maximum_age'] = 20;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment