|
| 1 | +# Setup Cache service with Redis Cache |
| 2 | +To complete this setup, you need an active Redis server. |
| 3 | +A good option when deploying on Openshift is using *Redis Enterprise Operator* provided by Redis (marked as Certified, official Redis Docs [here](https://redis.io/docs/latest/operate/kubernetes/deployment/openshift/openshift-operatorhub/)), but any Redis instance should be fine; feel free to chose any deployment method you prefer. |
| 4 | + |
| 5 | +To enable the Cache service in RHDH, you need to add the following configuration to your app-config.yaml: |
| 6 | + |
| 7 | +``` |
| 8 | +backend: |
| 9 | + cache: |
| 10 | + store: redis |
| 11 | + connection: redis://user:[email protected]:PORT |
| 12 | +``` |
| 13 | +The `useRedisSets` option is no longer supported (from RHDH 1.5). |
| 14 | + |
| 15 | +## Use Redis with plugins |
| 16 | +The plugins using Redis are Techdocs (production-ready) and Bulk-import (tech preview). |
| 17 | + |
| 18 | +To use Redis with Techdocs, make sure you set the ttl parameter in the Techdocs section of your configuration, or the items won't be cached: |
| 19 | +``` |
| 20 | +# File: app-config.yaml |
| 21 | +
|
| 22 | +techdocs: |
| 23 | + # techdocs.generator is used to configure how documentation sites are generated using MkDocs. |
| 24 | + . |
| 25 | + . |
| 26 | + . |
| 27 | + cache: |
| 28 | + # Represents the number of milliseconds a statically built asset should |
| 29 | + # stay cached. Cache invalidation is handled automatically by the frontend, |
| 30 | + # which compares the build times in cached metadata vs. canonical storage, |
| 31 | + # allowing long TTLs (e.g. 1 month/year) |
| 32 | + ttl: 3600000 |
| 33 | +
|
| 34 | + # (Optional) The time (in milliseconds) that the TechDocs backend will wait |
| 35 | + # for a cache service to respond before continuing on as though the cached |
| 36 | + # object was not found (e.g. when the cache service is unavailable). The |
| 37 | + # default value is 1000 |
| 38 | + readTimeout: 500 |
| 39 | +``` |
| 40 | + |
| 41 | +## Troubleshooting |
| 42 | +The logs will no show any hint of the cache service being running correctly. You can set more verbose logging by passing the enviroment variable `LOG_LEVEL=debug` to your RHDH instance. |
| 43 | +You will only see error logs when a cache read is requested by any of the plugins (for example, when opening a Techdocs page). |
| 44 | +Some examples: |
| 45 | +- if you see errors like: |
| 46 | + ``` |
| 47 | + {"level":"\u001b[31merror\u001b[39m","message":"Request failed with status 500 NOAUTH Authentication required","plugin":"techdocs","service":"backstage","span_id":"f2f0499492ded848","timestamp":"2025-02-20 13:37:03","trace_flags":"01","trace_id":"c750094ef56da1412f217c3a2cd01ded","type":"errorHandler"} |
| 48 | + ``` |
| 49 | + or |
| 50 | + ``` |
| 51 | + {"level":"\u001b[31merror\u001b[39m","message":"Failed to create redis cache client WRONGPASS invalid username-password pair","service":"backstage","span_id":"cfaf6a6a2031a34d","timestamp":"2025-02-20 13:27:15","trace_flags":"01","trace_id":"c0196b4be2bb94bba433290d8311d18b","type":"cacheManager"} |
| 52 | + ``` |
| 53 | + make sure you have setup at least a password for the dafault user (or better, a proper user with the rights to access your Redis database) and that you are providing the correct values in the connection string |
| 54 | +- if you are a using ssl/tls (i.e. `rediss://user:[email protected]:PORT`), make sure all the certificates are in place and valid; if you are using self-signed certificates, the connection will probably fail to validate the CA; **for testing porpuses only **, you can set the `NODE_TLS_REJECT_UNAUTHORIZED=0` enviromnment variable to overcome this issue |
0 commit comments