Redis-Cluster cannot query the key

The reason why Vlaue cannot be queried by Redis Cluster

Article Directory

What is redis

What is Cluster


​ The architecture used by the company's Redis is the Cluster model, as shown in the figure below, which is also for scalability, and HA. The previous production environment was normal and there was no problem. However, it was suddenly discovered that some KEYs cannot query Redis. The data, the database is queried, and the magnitude is not very large, but in the process of replacing the old and new businesses of a department, due to rapid iteration (saving trouble, laziness) for agile development, the latest operations directly modify the cache. Without updating the database, if noSql data cannot be queried, dirty data will be generated, which is a headache, so it is very simple to quickly locate the problem and solve it, and the business solution is also very simple.


  1. Local cache data ->Redis ->Mysql
  2. Redis cannot query data-query data again -> Mysql
  3. Redis can't query data ->Nocos/(Apollo)->Mysql

The problem can be solved in business, but why does it happen that it cannot be queried? The client we use is


The official preferred recommended client, the Maven package is

Jedis introduction

Insert picture description here

Officially provided Demo

    public void ConnectionTest(){
        //1. Connecting to Redis server on localhost
        Jedis jedis = new Jedis("localhost");
        System.out.println("Connection to server sucessfully");
        //2. set the data in redis string
        jedis.set("username", "Roxin");
        //3. Get the stored data and print it
        System.out.println("Stored string in redis:: "+ jedis.get("username"));
        //4. Close the Redis connection;

Pooled connection

    public void ConnectionPoolTest(){
        JedisPoolConfig config = new JedisPoolConfig();
        JedisPool jedisPool = new JedisPool(config, "");
        Jedis jedis = jedisPool.getResource();;
        jedis.set("username", "Roxin By Jedis Pool");

Jedis sample code

    public void SetTest(){
        Jedis jedis = jedisPool.getResource();
        String setKey1 = "SETKEY-1";
        for (int i = 0; i < 10; i++) {
        assert 10 == jedis.scard(setKey1); //获得元素个数
        assert 10 == jedis.scard(setKey1);
        String s= jedis.srandmember(setKey1);//随机获取一个元素
        assert jedis.sismember(setKey1,s);//是否为集合成员
        String setKey2 = "SETKEY-2";
        for (int i = 1; i < 11; i++) {
        assert jedis.sdiff(setKey1,setKey2).size() == 1;//补集
        assert jedis.sinter(setKey1,setKey2).size() == 9;//交集
        assert jedis.sunion(setKey1,setKey2).size() == 11;//并集

The cluster architecture

Cluster architecture

Cluster query process is like this

Query process

The reason why the data cannot be queried is probably

  1. Serialization issues
  2. Jedis problem concurrency socket can not be queried
  3. Problems with RedisTemplate
  4. Problems with Redis Cluster
  5. Re-allocate the card slot
  6. Connection timed out
  7. Bigkey
  8. NIC problem