Redis server

P4 Code Review uses Redis to manage cache data and includes project cache performance features that reduce Redis traffic and improve performance when working with large projects. The cache improves the performance of common searches and reduces load on the P4 Server. By default, P4 Code Review uses the bundled Redis server.

To monitor project cache usage and identify oversized projects, see Project Cache (System information).

Overview

If users or groups are added, modified, or deleted in the P4 Server while P4 Code Review is offline, the Redis cache can become out of sync with the P4 Server. After P4 Code Review restarts, you can manually verify the Redis caches. For details, see Manually verify the Redis caches.

When P4 Code Review starts, it verifies the Redis cache before allowing users to log in. The amount of time required depends on the number of users, groups, and projects stored in P4 Code Review.

A configuration change only takes effect when the configuration cache has been reloaded. You must be an admin or super user to reload the P4 Code Review config cache.

To reload the configuration:

  1. Open the user menu (top-right corner of P4 Code Review).

  2. Select System Information.

  3. Open the Cache Info tab.

  4. Click Reload Configuration.

If changes to the config.php file might have caused the P4 Code Review web interface to become unresponsive, remove the problematic changes from the config.php file, then clear the configuration cache by running this command: rm -f /opt/perforce/swarm/data/cache/module-config-cache.php

Redis connection settings

The redis connection settings are configured in the SWARM_ROOT/data/config.php file.

For details about:

  • Redis connection settings.

  • Configuration examples.

  • Redis namespaces.

  • Integrity checks.

  • Connection options.

  • Valkey configuration.

See Redis configuration options.

Redis server configuration file

The Redis server configuration is stored in the /opt/perforce/etc/redis-server.conf file.

For information about:

  • Default Redis settings.

  • Redis startup configuration.

  • Performance tuning.

  • Redis services.

  • Laminas Redis adapter settings.

See Redis configuration options.

Manually verify the Redis caches

In normal operation, the Redis cache and P4 Server remain synchronized and manual cache verification is not required. However, the cache can become out of sync in some situations, such as:

  • Changes are made in the P4 Server while P4 Code Review is offline.

  • Errors occur during cache updates.

If you suspect a cache issue, you can manually verify the cache from the System Information page. To learn more, see Cache Info.

Note:

  • Only admin and super users can verify Redis caches.

  • Cache verification can take time on systems with large numbers of users, groups, or projects.

  • On large systems, verifying individual caches is usually more efficient than using Verify All.

Cache batching

P4 Code Review batches Redis cache operations to prevent large single calls from blocking the Redis server. Two configuration keys in the redis block of SWARM_ROOT/data/config.php file control the batch sizes for write and read operations.

Key Operation Default Description

items_batch_size

Write (MSET) 10000

Maximum number of key/value pairs sent in a single MSET call when populating or updating the cache. Sets that exceed this limit are split into batches of this size.

items_read_batch_size

Read (MGET)

1000

Maximum number of keys sent in a single MGET call when reading cached records. Reads that exceed this limit are split into batches of this size. Available from P4 Code Review 2026.3 onwards.

items_read_batch_bytes

Read (MGET)

16M

Limits the total amount of cached data retrieved in a single read batch.

Redis processes commands on a single thread. A single MGET or MSET call with hundreds of thousands of keys blocks all other Redis operations until it completes. In environments with large numbers of users, groups, or workflows, unbatched calls can block Redis for hundreds of milliseconds, degrading the entire P4 Code Review environment.

In environments with very large projects, byte-based batching prevents a single large project from delaying smaller projects in the same read operation.

Batching configuration guidance:

  • The default values are suitable for most environments.

  • Smaller values reduce the time each Redis call blocks the server but increase the total number of round trips. In most cases the difference in round-trip overhead is negligible.

  • If you have more than 100,000 cached entities (users, groups, or workflows), the default items_read_batch_size of 1000 keeps individual MGET calls in the sub-millisecond range.

  • There is rarely a reason to change items_batch_size from its default. Cache population (writes) happens infrequently compared to reads.

Project cache performance features

P4 Code Review includes several project cache performance features that reduce Redis traffic and improve performance when working with large projects.

Most of these features are enabled by default and require no configuration. Compression and host-wide project caching are optional features that must be enabled manually.

To monitor project cache usage and identify oversized projects, see Project Cache (System information).

Project reuse

P4 Code Review can temporarily reuse project data that has already been retrieved from Redis. This reduces repeated cache reads when the same project is accessed multiple times during a request or queue worker operation.

Project reuse is enabled by default and helps reduce Redis traffic in environments where projects are accessed frequently.

Setting Default Description

project_read_memo_ttl

30

Controls how long project data can be reused after it has been read.

Set to 0 to disable project reuse.

project_read_memo_max_memory

256M

Controls the maximum amount of memory used for cached project reuse.

Set to 0 to remove the limit.

Project summary cache

P4 Code Review maintains a lightweight project summary cache that excludes branch path information. This allows many operations to retrieve project details without loading the complete project definition.

The summary cache helps improve performance when displaying project information and reduces the amount of data transferred between P4 Code Review and Redis.

Setting Default Description

project_summary_key

true

Maintains a lightweight copy of project data that excludes branch paths. This feature is enabled by default.

Project cache compression

Project cache compression reduces the amount of Redis storage required for project data. This can be particularly beneficial for deployments with large projects or projects that contain many branch paths.

Compression is optional and disabled by default. When enabled, existing cached data continues to function normally and no cache rebuild or migration is required.

Setting Default Description

compress_threshold

0

Specifies the minimum size a cached value must reach before compression is applied. Compression is disabled when set to 0.

compress_algorithm

auto

Specifies the compression algorithm used for compressed cache values. The auto option uses zstd when available and falls back to zlib.

Host-wide project cache

A host-wide project cache allows PHP worker processes running on the same server to share cached project data. This reduces repeated Redis reads and can improve performance when multiple requests access the same project.

Host-wide caching is optional and requires the APCu PHP extension. If APCu is unavailable, P4 Code Review automatically continues to use Redis without affecting normal operation.

Setting Default Description

project_l1_cache

false

Enables host-wide project caching.

Verify the User cache

  1. Open the user menu (top-right corner of P4 Code Review).

  2. Select System Information.

  3. Open the Cache Info tab.

  4. Click Verify User.

P4 Code Review displays a confirmation message when verification completes successfully.

If verification detects that the cache is out of sync with the P4 Server, P4 Code Review automatically updates the affected cache.

To learn more see Verify buttons

Check progress of the verification request

To check the progress of a verification request:

  1. Open the user menu (top-right corner of P4 Code Review).

  2. Select System Information.

  3. Select the Cache Info tab.

  4. Click Refresh Status.