0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added support for non cluster connections in the redis cache adapter

Previously, the adapter was only built for a redis cluster connection. Meaning
if you tried to use if with a redis that was a single node it would fail as it
tries to find a primary node. In a single node setup there is no primary node,
just the one main node. So, this update tricks the adapter into thinking it has
found a pimary node by returning the whole connection (to the single node) when
the constructor is note a cluster.
This commit is contained in:
Joe Grigg 2023-03-13 09:17:35 +00:00 committed by Fabien 'egg' O'Carroll
parent 67426d5c35
commit ed38760c6d

View file

@ -54,6 +54,9 @@ class AdapterCacheRedis extends BaseCacheAdapter {
}
#getPrimaryRedisNode() {
if (this.redisClient.constructor.name !== 'Cluster') {
return this.redisClient;
}
const slot = calculateSlot(this.keyPrefix);
const [ip, port] = this.redisClient.slots[slot][0].split(':');
for (const node of this.redisClient.nodes()) {