Please read the following tips and tell me how you feel.
Currently, Jedis does not support dynamic sharding.
If we add/remove an apsaradb for Redis Server from the available list, we can achieve this only by stopping the program, changing the shard configuration, and then restarting.
This implementation allows a series of things, like:
Adding/removing servers does not require downtime
External Redis connectivity detection and adjustment of Pseudo Real-Time shard Configuration
Sharding configuration for a cluster in a database or something similar
This scheme authorizes the sharding to configure a Jedis external component to dynamically update the sharding configuration without stopping services.
The JedisDynamicShardsProvider class is a bridge between components and Jedis.
The external component manages the shard configuration. When an update is required, it will call the relevant Method add/removeShard () or setShards () in JedisDynamicShardsProvider.
After this call, JedisDynamicShardsProvider notifies the Sharded instance of a change (inspired by the observer mode)
When Sharded processes a notification, all the "read" requests are locked until the shard configuration is changed (ReentrantReadWriteLock usage ).