Helix Core is now P4 and Helix Swarm is now P4 Code Review. Product user interfaces will be updated soon. Learn more >>

Documentation | 2025.3

# Redis configuration

P4 Code Review requires Redis to manage its caches and by default P4 Code Review uses its own Redis server on the P4 Code Review machine. P4 Code Review caches data from the P4 Server to improve the performance of common searches in P4 Code Review and to reduce the load on the P4 Server. Redis is included in the P4 Code Review Tarball installation.

This section describes how to configure the P4 Code Review Redis service on the P4 Code Review machine. Do not change the default values of the following configuration files if you are using the P4 Code Review Redis server.

If required, you can use your own Redis server instead of the P4 Code Review Redis server. For instructions on how to configure P4 Code Review to use your own Redis server, see Use your own Redis server.

P4 Code Review has two Redis binaries in SWARM_ROOT/p4-bin/bin.linux26x86_64/:

- redis-server-swarm
- redis-cli-swarm

1. Configure the Redis cache database, enter the following details in the redis-server.conf file in /opt/perforce/etc/:

    bind 127.0.0.1
    port 7379
    supervised auto
    save ""
    dir /opt/perforce/swarm/redis

Default values:

- The default settings are shown below, the redis-server.conf file contains more detailed information about the Redis configuration for P4 Code Review.
- On P4 Code Review systems with a large number of users, groups, and projects, start-up time can be improved by persisting the memory cache. You can persist the memory cache by disabling background saves and enabling append saves, see the redis-server.conf file comments for detailed information.

- bind 127.0.0.1 - Redis server IP address (loopback interface)
- port 7379 - Redis server port number
- supervised auto - detects the use of upstart or systemd automatically to signal that the process is ready to use the supervisors
- save "" - background saves disabled, recommended.
- dir /opt/perforce/swarm/redis - the directory the Redis cache database is stored in.

To fine-tune your Redis server settings, make your changes in the Laminas Redis adapter. For information about the Laminas Redis adapter, see the Laminas Redis Adapter documentation.

2. The Redis cache database must be running before P4 Code Review starts so we recommend setting it up as a service so that it starts automatically at boot time.

The following example script will:

- run the Redis service as the Perforce user
- use the configuration file in /opt/perforce/etc/redis-server.conf
- assume the database server is installed in /opt/perforce/swarm/p4-bin/bin.linux26x86_64/

To configure Redis as a service, add a script with the following content in /etc/systemd/system

redis-server-swarm.service

    [Unit]
    Description=Redis Server for Swarm
    After=network.target

    [Service]
    ExecStart=/opt/perforce/swarm/p4-bin/bin.linux26x86_64/redis-server-swarm /opt/perforce/etc/redis-server.conf
    ExecStop=/opt/perforce/swarm/p4-bin/bin.linux26x86_64/redis-cli-swarm shutdown
    Restart=always
    RestartSec=10
    StandardOutput=syslog
    StandardError=syslog
    SyslogIndentifier=redis
    User=perforce
    	Group=perforce

    [Install]
    WantedBy=multi-user.target

3. Create the `SWARM_ROOT/data/config.php` file if it does not already exist. The redis block of the `SWARM_ROOT/data/config.php` file contains the password, namespace, host and port details of the P4 Code Review Redis server:

    <?php
        // this block should be a peer of 'p4'
        'redis' => array(
            'options' => array(
                'password' => null, // Defaults to null
                'namespace' => 'Swarm',
                'server' => array(
                    'host' => 'localhost', // Defaults to 'localhost' or enter your Redis server hostname
                    'port' => '7379', // Defaults to '7379' or enter your Redis server port
                ),
            ),
            'items_batch_size' => 100000,
            'check_integrity' => '03:00', // Defaults to '03:00' Use one of the following two formats:
                                          // 1) The time of day that the integrity check starts each day. Set in 24 hour format with leading zeros and a : separator
                                          // 2) The number of seconds between each integrity check. Set as a positive integer. Specify '0' to disable the integrity check.
            'population_lock_timeout' => 300, // Timeout for initial cache population. Defaults to 300 seconds.
        ),

Configurables:

- password: Redis server password. Defaults to null and should be left at default if using the P4 Code Review Redis server.
- namespace: the prefix used for key values in the Redis cache. Defaults to Swarm and should be left at default if using the P4 Code Review Redis server.

If you have multiple P4 Code Review instances running against a single Redis server, each P4 Code Review server must use a different Redis namespace. This enables the cache data for the individual P4 Code Review instances to be identified. The namespace is limited to ≤ 128 characters.

If one or more of your P4 Code Review instances is connected to multiple P4 Servers, the Redis namespace includes the server label and the character limit is reduced to ≤ 127 characters, see Multiple P4 Server instances.

- host: Redis server hostname. Defaults to localhost and should be left at default if using the P4 Code Review Redis server.
- port: Redis server port number. Defaults to 7379. P4 Code Review uses port 7379 as its default to avoid clashing with other Redis servers that might be on your network. It should be left at default if using the P4 Code Review Redis server. The default port for a non-P4 Code Review Redis server is 6379.
- items_batch_size: Maximum number of key/value pairs allowed in an mset call to Redis. Sets exceeding this will be batched according to this maximum for efficiency. Defaults to 100000.

The default value of 100000 was chosen to strike a balance between efficiency and project data complexity. This value should not normally need to be changed, contact support before making a change to this value.

- check_integrity: In some circumstances, such as when changes are made in the P4 Server when P4 Code Review is down or if errors occur during updates, the Redis cache can get out of sync with the P4 Server. P4 Code Review can run a regular integrity check to make sure that the Redis caches and P4 Server are in sync. If an integrity check finds an out of sync cache file, P4 Code Review automatically updates the data in that cache.

The check_integrity configurable specifies when the Redis cache integrity check is run. Set as a specific time of day (24 hour format with leading zeros) or a number of seconds (positive integer) between checks. Disable the integrity check with '0'. Defaults to '03:00'.

- population_lock_timeout: specifies the timeout, in seconds, for initial cache population. If you have a large P4 Code Review system, increase this time if the initial cache population times out. Defaults to 300 seconds.

Configure Apache, see Apache configuration.

Your search for returned results