Example command

The following example enables Redis default caching, sets the host to 127.0.0.1, and assigns the database number to 0. Redis uses default values for all other parameters.

bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=127.0.0.1 --cache-backend-redis-db=0

Configure Redis page caching

To configure Redis page caching on Commerce, run the setup:config:set command with additional parameters.

bin/magento setup:config:set --page-cache=redis --page-cache-redis-<parameter>=<value>...

With the following parameters:

  • --page-cache=redis enables Redis page caching. If this feature has already been enabled, omit this parameter.

  • --page-cache-redis-<parameter>=<value> is a list of key-and-value pairs that configure page caching:

Command-line parameterValueMeaningDefault value
page-cache-redis-serverserverFully qualified hostname, IP address, or an absolute path to a UNIX socket. The default value of 127.0.0.1 indicates Redis is installed on the Commerce server.127.0.0.1
page-cache-redis-portportRedis server listen port6379
page-cache-redis-dbdatabaseRequired if you use Redis for both the default and full page cache. You must specify the database number of one of the caches; the other cache uses 0 by default.
Important: If you use Redis for more than one type of caching, the database numbers must be different. It is recommended that you assign the default caching database number to 0, the page-caching database number to 1, and the session storage database number to 2.
0
page-cache-redis-passwordpasswordConfiguring a Redis password enables one of its built-in security features: the auth command, which requires clients to authenticate to access the database. Configure the password within the Redis configuration file: /etc/redis/redis.conf