Redis server, cluster settings, master-slave, slave has no data, the reason is unknown. Use a virtual one to drift data to the main redis server. The set key is not visible on the main server. The virtual one cannot be played, but it can be retrieved. There is no data in the slave redis service. The key is that you can get the expiretime to be zero through the method, but you can get the value corresponding to the key. Now that there are other redis servers, where is the data stored? Why is the expire value zero, and can I still get the value corresponding to the key? ? ? Finally, after shutting down the slave redis, restarting the master server, and pointing the IP to the master redis server, the problem was solved. The reason is unknown. Where did the data go?
Supplement: If you set an unstable key with a key-value that has an expiration time, please pay attention! If you use the method of setting expiretime to 0 to delete the key, redis may not delete it immediately. Use the hasKey method of spring data redis to determine whether the key exists, and then you will fall into a trap, because even if the expiretime is 0, the key may not have been deleted, redis expires The key uses lazy expiration: when accessing the key, it is determined whether the key has expired. If it expires, expiration processing is performed. Secondly, volatile keys are sampled and tested every second. If there are expired keys, all expired keys are processed. We have no idea what settings this patrol speed is related to and how efficient it is. Therefore, when you set an unstable key and use hasKey to make a judgment, please note that you need to obtain the expiration time of the key and then make a judgment yourself.
The first edition of "Redis Design and Implementation" has explanations of the principles. If you are interested, you can search for it
Redis server, cluster settings, master-slave, slave has no data, the reason is unknown. Use a virtual one to drift data to the main redis server. The set key is not visible on the main server. The virtual one cannot be played, but it can be retrieved. There is no data in the slave redis service. The key is that you can get the expiretime to be zero through the method, but you can get the value corresponding to the key. Now that there are other redis servers, where is the data stored? Why is the expire value zero, and can I still get the value corresponding to the key? ? ?
Finally, after shutting down the slave redis, restarting the master server, and pointing the IP to the master redis server, the problem was solved.
The reason is unknown.
Where did the data go?
Supplement:
If you set an unstable key with a key-value that has an expiration time, please pay attention! If you use the method of setting expiretime to 0 to delete the key, redis may not delete it immediately.
Use the hasKey method of spring data redis to determine whether the key exists, and then you will fall into a trap, because even if the expiretime is 0, the key may not have been deleted,
redis expires The key uses lazy expiration: when accessing the key, it is determined whether the key has expired. If it expires, expiration processing is performed. Secondly, volatile keys are sampled and tested every second. If there are expired keys, all expired keys are processed.
We have no idea what settings this patrol speed is related to and how efficient it is. Therefore, when you set an unstable key and use hasKey to make a judgment, please note that you need to obtain the expiration time of the key and then make a judgment yourself.
The first edition of "Redis Design and Implementation" has explanations of the principles. If you are interested, you can search for it