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:
parent
67426d5c35
commit
ed38760c6d
1 changed files with 3 additions and 0 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue