Enable Object Cache for Drupal
How to install and configure Object Cache for Drupal.
Drupal 9.3+ / Composer-managed
-
Navigate to your Pantheon Site Dashboard, select Settings, select Add Ons, then select Add to enable the Redis cache server. It might take a couple of minutes for the Redis server to come online.
-
Clone the code repository and run the following from the project root:
-
Enable the new Redis module and export configuration:
-
Edit
sites/default/settings.phpto add the Redis cache configuration. These are mandatory, required Redis configurations for every site:Information:NoteThe above Redis cache configuration should be placed in
sites/default/settings.php, rather thansettings.pantheon.php, to avoid conflicts with future upstream updates.
Database Cleanup (Required)
After enabling Redis, there are cache tables in the database that are no longer being used. Even when the Drupal cache is cleared, these tables will not be emptied. For sites that were live for awhile before Redis was enabled, there could be significant amounts of data in these tables. Removing this data could increase the speed of cloning, exporting, and backing up the database.
Use the following script to cleanup cache tables in the database:
Drupal 7
This configuration uses the Redis_CacheCompressed class for better performance. This requires the Redis module version 3.13 or later. For versions before 3.13, use Redis_Cache in step 4 instead.
-
Navigate to your Pantheon Site Dashboard, select Settings, select Add Ons, then select Add to enable the Redis cache server. It might take a couple of minutes for the Redis server to come online.
-
Add the Redis module from Drupal.org. You can install and enable the module from the command line using Terminus:
-
Ignore the directions bundled with the Redis module. Pantheon automatically manages the following
settings.php/$conf/variable_getitems for you:redis_client_hostredis_client_portredis_client_password
-
Edit
sites/default/settings.phpto add the Redis cache configuration. These are the mandatory, required Redis configurations for every site.
-
Enable the module via
/admin/modules, if you haven't already done so, using Terminus. -
Navigate to the dashboard and click Connection Info to verify that Redis is enabled. If you see the Redis cache connection string, Redis is enabled.
-
Visit
/admin/config/development/performance/redisand open Connection Information to verify the connection. -
See the "Database Cleanup" section above for steps on how to truncate the existing cache tables to make sure the latest data populates object cache properly.