Skip to main content

Use Redis as a shared cache (on-premises)

You can configure Contrast to use a shared cache on a Redis server.

This topic does not provide details about setting up Redis servers.

Contrast properties for Redis

Use these properties:

Property name

Description

cache.useredis

A Boolean value indicating whether Contrast uses Redis for caches.

contrast.cache.redis.db.index

An Integer specifying the database index where Contrast stores cache information.

contrast.cache.redis.proto

A string that controls which protocol to use when Contrast connects to the Redis server.

contrast.cache.redis.host

A string containing the host name or IP address of the Redis server.

contrast.cache.redis.port

An Integer representing the TCP/IP port that the Redis server uses using to listen for new client connections.

contrast.cache.redis.password

A string containing the password used to authorize client access to the Redis server.

contrast.cache.redis.client.name

A string that identifies the client.

Before you begin

  • You need this information:

    • The host name or IP address for the Redis server

    • The listening port for the Redis server

    • The password for a user account on the Redis server

    • The database index that the cache should target

  • Verify that the Redis server is configured to use TLS (REDISS)

Steps

  1. Create a contrast.properties file in the /data/conf/ folder.

    Ensure this file has the correct permissions to let a contrast_server user access it.

  2. In the property file, add the Contrast properties for Redis.

    At a minimum, configure values for the host name, listening port, and password for the Redis server.

    Property file example:

    cache.useredis=true
    contrast.cache.redis.db.index=0
    contrast.cache.redis.proto=rediss
    contrast.cache.redis.host=contrast-redis-server.company.com
    contrast.cache.redis.port=6379
    contrast.cache.redis.password=changeme
    contrast.cache.redis.client.name=contrast
  3. Restart Contrast.

  4. To verify the configuration look in the /data/logs/contrast.log file.

    This file contains all the information on the current configuration and interactions with Redis. Key terms to look for include:

    • RedissonCache

    • Redisson

    • CacheConfiguration