Redis Configuration

Last Updated: 01 May 2018

Redis cache storage can be configured on a Squiz Matrix system as an alternative to Matrix cache.

The cache storage enhancements using Redis require the phpredis PECL extension installed. For more information, refer to the phpredis documentation (GitHub).


Configuring the Redis Hosts

Redis host servers can be configured within the system's file (~/data/private/conf/ The default layout of the hosts array section of this file is shown below:

   'hosts' =>Array (
               'redis1' => Array(
                       'socket' => false,
                       'host'   => '',
                       'port'  => 6379
               'redis2' => Array(
                       'socket' => false,
                       'host'   => '',
                       'port'  => 6380

       // List of Matrix services utilising the above servers.
       // Indexed by key => weight.
       'services'  => Array(
               'cache_manager'     => Array('redis1' => 1, 'redis2' => 1),
               'session_handling'  => Array('redis1' => 1, 'redis2' => 1),
               'locking'           => Array('redis1' => 1, 'redis2' => 1),
               'deja_vu'           => Array('redis1' => 1, 'redis2' => 1),

Multiple hosts can be defined within this array, as displayed in the default layout of the file. The parameters available for configuration are as follows:

  • socket: the path to a Unix domain socket to connect to. Please note that entering socket information within this parameter will override any host and port values that have been set. By default, this option is set to False.
  • host: the hostname of the Redis server where the Redis server is listening for connections.
  • port: the port of the Redis server. By default, this is set to 6379 (default port) for the redis1 host, and 6380 for the redis2 host.
  • database: which database in Redis to use (default is 0)
  • persistent: whether to keep the connection open for the duration of the PHP request (default is false)
  • persistent_id: the identifier for a persistent connection (default is '')
  • retry_interval: time between reconnection attempts in milliseconds (default is 2)
  • prefix: a prefix for all keys (default is '')
  • read_timeout: a maximum amount of time to wait for data from Redis in seconds (default is 0, which means unlimited)

For more information on these parameters, refer to the Redis documentation.

Setting Up the Redis Services

Squiz Matrix offers Redis services that can be configured within the system's file (~/data/private/conf/ once the Redis host servers have been configured. The default layout of the services section of the file is shown below:

'cache_manager'     => Array('redis1' => 1, 'redis2' => 1),
'session_handling'  => Array('redis1' => 1, 'redis2' => 1),
'locking'           => Array('redis1' => 1, 'redis2' => 1),
'deja_vu'           => Array('redis1' => 1, 'redis2' => 1),

By default, the cache_manager service will be utilising the redis1 and redis2 default host set up.

To configure hosts for these redis services, add the host server ID to the service array, as follows:

'cache_manager'     => Array('redis1' => 1)

In this example, the redis1 host server has been set to 1 (true). You can configure multiple hosts on these services, as in the default host set up. This is useful to create a fallback if the initial host cannot be reached or fails. This is achieved like so:

'cache_manager'     => Array('redis1' => 1, 'redis2' => 1

Continue reading below for more information on the services available for Redis.

Cache Manager

The Redis cache_manager service allows you to store Matrix cache entries within Redis rather than the default SQ_CACHE directory (specified in

The cache storage system is fully optional for Redis and is configured in the file. The default set up of this service is as follows:

'cache_manager'     => Array('redis1' => 1, 'redis2' => 1)

Once you have configured the file, you can enable Redis cache storage on the Details screen of the Cache Manager.

The Redis Cache Storage option

In the Cache Storage Type field, select Redis Cache Storage and click Commit. Redis cache storage will now be enabled on your system, using the Redis server settings specified in the file.

Previous Chapter Next Chapter

The Latest

Let Us Know What You Think

Let us know if you spot any errors or if you have any ideas on how we can improve the Matrix Community Website.

Contact Squiz for Demo

Let us show you the true power of Squiz Matrix by giving you a personalised demonstration.