From ed38760c6d36e119aa8db5b3bf63fad3064db6e1 Mon Sep 17 00:00:00 2001 From: Joe Grigg Date: Mon, 13 Mar 2023 09:17:35 +0000 Subject: [PATCH] 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. --- ghost/adapter-cache-redis/lib/AdapterCacheRedis.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ghost/adapter-cache-redis/lib/AdapterCacheRedis.js b/ghost/adapter-cache-redis/lib/AdapterCacheRedis.js index 981109e65f..a8811773e7 100644 --- a/ghost/adapter-cache-redis/lib/AdapterCacheRedis.js +++ b/ghost/adapter-cache-redis/lib/AdapterCacheRedis.js @@ -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()) {