Using Redis with Lando
Redis is a key-value store than can be used for the Drupal cache, taking this out of the database and increasing Drupal performance.
Adding a Redis service
For the Lando docs on installing Redis see: https://docs.devwithlando.io/services/redis.html
Edit the .lando.yml file and add the following a cache server to the services section.
services:
...
cache:
type: redis:4.0
portforward: 6380
persist: true
In the tooling section add access to the redis-cli command.
tooling:
...
redis-cli:
service: cache
Then run lando rebuild to add the service.
Configure Drupal to use Redis
The Drupal Redis module is required to use Redis with Drupal.
Enable the module and then add the following to the site's settings.php (Drupal 7) or settings.local.php (Drupal 8+):
/**
* Redis Configuration.
*/
$conf['redis_client_interface'] = 'PhpRedis';
$conf['redis_client_host'] = 'cache';
$conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc';
$conf['path_inc'] = 'sites/all/modules/contrib/redis/redis.path.inc';
$conf['cache_backends'][] = 'sites/all/modules/contrib/redis/redis.autoload.inc';
$conf['cache_default_class'] = 'Redis_Cache';
Clear the cache the you should see that Redis is enabled and running in the site's status page.
To check that data is being stored in Redis run
lando redis-cli keys "*cache_boot*"
Last updated: