others-How to solve ClusterRedirectException(JedisMovedDataException: MOVED)
1. The purpose of this post
I would demo how to solve this error when using SpringBoot and Redis cluster
SpringBoot 1.x or 2.x
3. Solution and Code
You can connecting a node in redis cluster using a non-cluster mode.
According to redis official documents:
Keys distribution model
The key space is split into 16384 slots, effectively setting an upper limit for the cluster size of 16384 master nodes (however the suggested max size of nodes is in the order of ~ 1000 nodes).
Each master node in a cluster handles a subset of the 16384 hash slots. The cluster is stable when there is no cluster reconfiguration in progress (i.e. where hash slots are being moved from one node to another). When the cluster is stable, a single hash slot will be served by a single node (however the serving node can have one or more slaves that will replace it in the case of net splits or failures, and that can be used in order to scale read operations where reading stale data is acceptable).
3.1 Solution 1
Connect your redis cluster using cluster mode like this:
3.2 Solution 2
Setup a single-node redis server, and connect to it: