Shlink can take advantage of redis in multiple contexts.
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 openswoole or 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.
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.
Shlink supports multiple redis capabilities, depending on how the configuration is provided:
- Redis instance, when providing just one server (for example,
- Redis cluster, when providing multiple servers (for example,
- 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 (
Prior to Shlink 3.7.0, password-only URIs had to have the form
Since that’s not a valid URI, it is considered deprecated, and will be removed in Shlink 4.0.0
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.
[...] INTEGRATIONS ============ 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 [...]