Skip to content

Instantly share code, notes, and snippets.

@riteshgurung
Forked from keopx/settings.local.php
Created May 29, 2022 17:22
Show Gist options
  • Save riteshgurung/8d73a35db54fb8ddb43911e05dd86ecf to your computer and use it in GitHub Desktop.
Save riteshgurung/8d73a35db54fb8ddb43911e05dd86ecf to your computer and use it in GitHub Desktop.

Revisions

  1. @keopx keopx revised this gist May 16, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions settings.local.php
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,7 @@
    $settings['redis.connection']['host'] = 'redis';
    $settings['redis.connection']['port'] = '6379';
    // $settings['redis.connection']['password'] = "mypassword"; // If you are using passwords, otherwise, omit
    $settings['redis.connection']['persistent'] = TRUE; // Persistant connection.

    // Apply changes to the container configuration to better leverage Redis.
    // This includes using Redis for the lock and flood control systems, as well
  2. @keopx keopx revised this gist Jul 10, 2017. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion settings.local.php
    Original file line number Diff line number Diff line change
    @@ -56,7 +56,10 @@
    ],
    ],
    ];


    /** Optional prefix for cache entries */
    $settings['cache_prefix'] = 'any-text-you-want';

    /** @see: https://pantheon.io/docs/redis/ */
    // Always set the fast backend for bootstrap, discover and config, otherwise
    // this gets lost when redis is enabled.
  3. @keopx keopx revised this gist Jun 18, 2017. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions settings.local.php
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,17 @@
    <?php

    /**
    * Set redis configuration.
    */
    /** @see: https://docs.platform.sh/frameworks/drupal8/redis.html */
    if (extension_loaded('redis')) {

    // Set Redis as the default backend for any cache bin not otherwise specified.
    $settings['cache']['default'] = 'cache.backend.redis';
    // $settings['cache']['default'] = 'cache.backend.redis';
    $settings['redis.connection']['interface'] = 'PhpRedis'; // Can be "Predis".
    $settings['redis.connection']['host'] = 'redis';
    $settings['redis.connection']['port'] = '6379';

    /** @see: below $class_loader->addPsr4() */
    // $settings['redis.connection']['interface'] = 'PhpRedis'; // Can be "Predis".
    // $settings['redis.connection']['password'] = "mypassword"; // If you are using passwords, otherwise, omit

    // Apply changes to the container configuration to better leverage Redis.
    // This includes using Redis for the lock and flood control systems, as well
    @@ -65,21 +65,21 @@
    $settings['cache']['bins']['config'] = 'cache.backend.chainedfast';

    /** @see: https://github.com/md-systems/redis */
    # Use for all bins otherwise specified.
    // Use for all bins otherwise specified.
    $settings['cache']['default'] = 'cache.backend.redis';

    # Use this to only use it for specific cache bins.
    // Use this to only use it for specific cache bins.
    $settings['cache']['bins']['render'] = 'cache.backend.redis';

    # Use for all queues unless otherwise specified for a specific queue.
    // Use for all queues unless otherwise specified for a specific queue.
    $settings['queue_default'] = 'queue.redis';

    # Or if you want to use reliable queue implementation.
    // Or if you want to use reliable queue implementation.
    $settings['queue_default'] = 'queue.redis_reliable';

    # Use this to only use Redis for a specific queue (aggregator_feeds in this case).
    // Use this to only use Redis for a specific queue (aggregator_feeds in this case).
    $settings['queue_service_aggregator_feeds'] = 'queue.redis';

    # Or if you want to use reliable queue implementation.
    // Or if you want to use reliable queue implementation.
    $settings['queue_service_aggregator_feeds'] = 'queue.redis_reliable';
    }
  4. @keopx keopx created this gist Jun 14, 2017.
    85 changes: 85 additions & 0 deletions settings.local.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,85 @@
    <?php
    /**
    * Set redis configuration.
    */
    /** @see: https://docs.platform.sh/frameworks/drupal8/redis.html */
    if (extension_loaded('redis')) {

    // Set Redis as the default backend for any cache bin not otherwise specified.
    $settings['cache']['default'] = 'cache.backend.redis';
    $settings['redis.connection']['host'] = 'redis';
    $settings['redis.connection']['port'] = '6379';

    /** @see: below $class_loader->addPsr4() */
    // $settings['redis.connection']['interface'] = 'PhpRedis'; // Can be "Predis".

    // Apply changes to the container configuration to better leverage Redis.
    // This includes using Redis for the lock and flood control systems, as well
    // as the cache tag checksum. Alternatively, copy the contents of that file
    // to your project-specific services.yml file, modify as appropriate, and
    // remove this line.
    $settings['container_yamls'][] = 'modules/contrib/redis/example.services.yml';

    // Allow the services to work before the Redis module itself is enabled.
    $settings['container_yamls'][] = 'modules/contrib/redis/redis.services.yml';

    // Manually add the classloader path, this is required for the container cache bin definition below
    // and allows to use it without the redis module being enabled.
    $class_loader->addPsr4('Drupal\\redis\\', 'modules/contrib/redis/src');

    // Use redis for container cache.
    // The container cache is used to load the container definition itself, and
    // thus any configuration stored in the container itself is not available
    // yet. These lines force the container cache to use Redis rather than the
    // default SQL cache.
    $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',
    ],
    ],
    ];

    /** @see: https://pantheon.io/docs/redis/ */
    // Always set the fast backend for bootstrap, discover and config, otherwise
    // this gets lost when redis is enabled.
    $settings['cache']['bins']['bootstrap'] = 'cache.backend.chainedfast';
    $settings['cache']['bins']['discovery'] = 'cache.backend.chainedfast';
    $settings['cache']['bins']['config'] = 'cache.backend.chainedfast';

    /** @see: https://github.com/md-systems/redis */
    # Use for all bins otherwise specified.
    $settings['cache']['default'] = 'cache.backend.redis';

    # Use this to only use it for specific cache bins.
    $settings['cache']['bins']['render'] = 'cache.backend.redis';

    # Use for all queues unless otherwise specified for a specific queue.
    $settings['queue_default'] = 'queue.redis';

    # Or if you want to use reliable queue implementation.
    $settings['queue_default'] = 'queue.redis_reliable';

    # Use this to only use Redis for a specific queue (aggregator_feeds in this case).
    $settings['queue_service_aggregator_feeds'] = 'queue.redis';

    # Or if you want to use reliable queue implementation.
    $settings['queue_service_aggregator_feeds'] = 'queue.redis_reliable';
    }