Using redis

Shlink can take advantage of redis in multiple contexts.

Caching purposes

Shlink can persist certain things in a faster storage for quick access.

By default, it uses APCu if available (when using a classic web server) or in-memory (when using Roadrunner as the runtimes), but it can be provided with some redis access configuration.

When doing so, Shlink will use redis as the cache persistence.

Shared locks


Locks are used to make sure certain tasks are not run more than once in parallel. For example, geolocating visits.

If you plan to run multiple Shlink instances, it’s important to make sure the so-called “locks” are shared between all of them.

Redis is a good way to do so. If Shlink is provided with redis access configuration, it will use it to store shared locks.

Supported capabilities

Shlink supports multiple redis capabilities, depending on how the configuration is provided:

  • Redis instance, when providing just one server (for example, tcp://my_redis_server:6379).
  • Redis cluster, when providing multiple servers (for example, tcp://one_redis_server:6379,tcp://another_redis_server:6379).
  • Redis sentinel, when providing multiple servers, together with a sentinel service name.
  • Credentials, that can be provided as part of the server URIs, either both username and password (tcp://the_username:the_password@my_redis_server:6379) or just password (tcp://:the_password@my_redis_server:6379).


Prior to Shlink 3.7.0, password-only URIs had to have the form tcp://the_password@my_redis_server:6379. Since that’s not a valid URI, it has been removed removed in Shlink 4.0.0

Providing configuration

As with any other configuration params, there are two main ways to provide redis options:

  • Environment variables, which allow you to enable the integration however you like.

  • The installation tool, which will, at some point, ask you if you want to integrate with redis, and request you to provide all the capabilities above if so.

     Do you want to use a redis instance, redis cluster or redis sentinels as a shared cache for Shlink? (recommended if you run a cluster of Shlink instances) (yes/no) [no]:
     > yes
     Provide a comma-separated list of URIs (redis servers/sentinel instances):
     > tcp://one_redis_server:6379,tcp://another_redis_server:6379
     Provide the name of the sentinel service (leave empty if not using redis sentinel):
     Do you want Shlink to publish real-time updates in this Redis instance/cluster? (yes/no) [no]:
     > yes