As with #2412563: amazon s3 storage service, it'd be nice to be able to provision Redis databases on a per-site basis, and inject the necessary settings into site settings.php. The redis module provides the site level functionality we'd need, and suggests the following entries in settings.php as a starting-point:

  $conf['redis_client_interface'] = 'PhpRedis'; // Can be "Predis".
  $conf['redis_client_host']      = '1.2.3.4';  // Your Redis instance hostname.
  $conf['lock_inc']               = 'sites/all/modules/redis/redis.lock.inc';
  $conf['path_inc']               = 'sites/all/modules/redis/redis.path.inc';
  $conf['cache_backends'][]       = 'sites/all/modules/redis/redis.autoload.inc';
  $conf['cache_default_class']    = 'Redis_Cache';

Again, as with S3 bucket provisioning, I'll write this in contrib. But I'll report progress in this issue, so as to provide more visibility. The initial plan is to focus on the integration points (see below), then later expand S3 into an AWS suite, and look at provisioning ElasticCache instances, etc.

I think all that'll be required initially is:

  1. site-level field for redis host
  2. site-level field for redis port (optional)
  3. save these to the site context
  4. inject them into settings.php

Additional stuff might include:

  • setting a prefix per site, so that a single Redis db can be shared across an Aegir instance.

As always, feedback is welcome.

Comments

Grimreaper’s picture

Hello,

I am interested with this feature.

Also how do you think to handle the cache during the install of the site?

As the redis module is not enabled yet during the install, the information in settings.php must be put after the install.

I currently handle that by checking the presence of an empty file (https://github.com/Drupal-FR/socle-drupalcampfr/blob/8.x-1.x/www/sites/d...) that is created in an install script.

Also is there a way to execute drush command during tasks such as:
- update translations with the drush_language extension during the verify of a site
- execute migrate imports after the site install

Grimreaper’s picture

Hello,

I think this feature can be achieved with the module https://www.drupal.org/project/hosting_variables.

Even though the last time I tested this module it did not work, see #2830540: Variables not written

helmo’s picture

Another way would be to add the required lines to local.settings.php

To run extra code during a task you could use a hook like drush_hook_post_COMMAND() e.g. drush_example_post_provision_verify().
As I could not find docs about this I opened a pull request to add them ... please review.

Grimreaper’s picture

Hello,

@helmo: Documentation looks good to me. Thanks.

helmo’s picture

Status: Active » Closed (won't fix)

"won't fix" sounds a bit harsh ... but I think the documented ways are 'good enough'.

Feel free to re-open if anyone wants to work on a dedicated Redis service implementation.