Redis https://cdn1.keopx.net/ es Cómo instalar y configurar Redis en Drupal 8 https://cdn1.keopx.net/blog/como-instalar-y-configurar-redis-en-drupal-8 <span>Cómo instalar y configurar Redis en Drupal 8</span> <div class="text-content clearfix field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Voy a explicar cómo <strong>instalar y configurar Redis en Drupal 8.</strong> </p> <p>Redis es una base de datos popular basado en key-value.</p> <p>En el caso de <a href="https://www.drupal.org">Drupal</a> se usa como sistema de cache para la parte (backend) de gestión de contenidos, donde el sistema de cachea "estático" de las paginas no es suficiente.</p> <p>Con Redis notaremos rápidamente la fluidez y rapidez con la que se puede gestionar toda la parte que requiere de usuarios autenticados.</p> <ol><li>Instalar <em>Redis</em>:<br /><pre> <code class="language-bash">sudo apt-get install redis-server</code></pre><p>También puedes ver <a href="https://github.com/keopx/docker-redis/blob/master/3.2/Dockerfile">Dockerfile</a></p> </li> <li>Instalar soporte de <em>Redis</em> para PHP:<br /><pre> <code class="language-bash">sudo apt-get install php7.0-redis sudo a2enmod php7.0-redis</code></pre><p>También puedes ver <a href="https://github.com/keopx/docker-apache-php/blob/master/7.0/Dockerfile">Dockerfile</a></p> </li> <li>Instalar el modulo <em>redis</em> de <em>Drupal</em>:<br /><pre> <code class="language-bash">composer require drupal/redis</code></pre><p>o</p> <pre> <code class="language-bash">drush dl redis</code></pre></li> <li> <p>Configurar <strong>redis</strong> para <strong>Drupal</strong>:</p> </li> </ol><p>En el <strong>settings.php</strong> o mejor en el drush añadir lo siguiente:</p> <pre> <code class="language-php">&lt;?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']['interface'] = 'PhpRedis'; // Can be "Predis". $settings['redis.connection']['host'] = 'redis'; $settings['redis.connection']['port'] = '6379'; // $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 // 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-&gt;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' =&gt; [], 'services' =&gt; [ 'redis.factory' =&gt; [ 'class' =&gt; 'Drupal\redis\ClientFactory', ], 'cache.backend.redis' =&gt; [ 'class' =&gt; 'Drupal\redis\Cache\CacheBackendFactory', 'arguments' =&gt; ['@redis.factory', '@cache_tags_provider.container', '@serialization.phpserialize'], ], 'cache.container' =&gt; [ 'class' =&gt; '\Drupal\redis\Cache\PhpRedis', 'factory' =&gt; ['@cache.backend.redis', 'get'], 'arguments' =&gt; ['container'], ], 'cache_tags_provider.container' =&gt; [ 'class' =&gt; 'Drupal\redis\Cache\RedisCacheTagsChecksum', 'arguments' =&gt; ['@redis.factory'], ], 'serialization.phpserialize' =&gt; [ 'class' =&gt; 'Drupal\Component\Serialization\PhpSerialize', ], ], ]; /** 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. $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'; } </code></pre><p>Ver <a href="https://gist.github.com/keopx/7d5fe4d7a890c792c43bb79cf56718e0">https://gist.github.com/keopx/7d5fe4d7a890c792c43bb79cf56718e0</a></p> <p>Una ves hecho esto ir a la pagina de estado (<em>/admin/reports/status</em>) para comprobar que todo esta bien.</p> <p><img alt="Drupal Redis Setup" data-entity-type="file" data-entity-uuid="54abaecf-03e5-4c6e-8bfe-f1e23743c011" src="/sites/default/files/inline-images/Drupal_redis.png" width="587" height="68" /></p> <p>NOTA: si veis que cualquier parametrización es mejor, por favor comentadlo. Gracias.</p> <p>Referencias:</p> <ul><li><a href="https://gist.github.com/keopx/7d5fe4d7a890c792c43bb79cf56718e0">https://gist.github.com/keopx/7d5fe4d7a890c792c43bb79cf56718e0</a></li> <li><a href="https://docs.platform.sh/frameworks/drupal8/redis.html">https://docs.platform.sh/frameworks/drupal8/redis.html</a></li> <li><a href="https://pantheon.io/docs/redis/">https://pantheon.io/docs/redis/</a></li> <li><a href="https://github.com/md-systems/redis">https://github.com/md-systems/redis</a></li> <li><a href="https://github.com/keopx/docker-lamp">https://github.com/keopx/docker-lamp</a></li> </ul><p> </p> <p> </p> </div> <span><span>keopx</span></span> <span><time datetime="2017-06-18T17:25:35+02:00" title="Domingo, Junio 18, 2017 - 17:25">Dom, 18/06/2017 - 17:25</time> </span> <div class="field field--name-field-tax-cat field--type-entity-reference field--label-above"> <div class="field__label">Categoria</div> <div class="field__items"> <div class="field__item"><a href="/categoria/drupal-8x" hreflang="es">Drupal 8.x</a></div> <div class="field__item"><a href="/categoria/redis" hreflang="es">Redis</a></div> <div class="field__item"><a href="/categoria/drupal" hreflang="es">Drupal</a></div> <div class="field__item"><a href="/categoria/drupal-planeta" hreflang="es">Drupal Planeta</a></div> </div> </div> <div class="field field--name-field-tax-tag field--type-entity-reference field--label-above"> <div class="field__label">Tag</div> <div class="field__items"> <div class="field__item"><a href="/tag/drupal" hreflang="es">Drupal</a></div> <div class="field__item"><a href="/tag/drupal-8x" hreflang="es">Drupal 8.x</a></div> <div class="field__item"><a href="/tag/redis" hreflang="es">Redis</a></div> <div class="field__item"><a href="/tag/php" hreflang="es">php</a></div> </div> </div> <section data-drupal-selector="comments" class="comments"> <h2 class="comments__title">Comentarios</h2> <div class="add-comment"> <div class="add-comment__form"> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=269&amp;2=field_comments&amp;3=comment" token="qCV33nxDY_ejWnQ4sUSyDpnaLr7joysNjRbFgsrijWE"></drupal-render-placeholder> </div> </div> </section> Sun, 18 Jun 2017 15:25:35 +0000 keopx 269 at https://cdn1.keopx.net