The project uses spring Redis cache as the cache client.
Spring Redis Cache Rediscache is the domain model for the entire spring cache, which corresponds to the operation class for a cache block.
The put,get,clean,evict operation is defined in Rediscache.
Where the clean method clears all the elements in the current cache block, it is locked, and the lock is implemented as a key to the Redis server: the cache block name plus the ~lock element. The final purge lock is cleared in finally after the clean method execution is complete.
The put and get methods run to see if a lock lock exists and sleep 300 milliseconds. This process continues until a lock is present on the Redis server and the corresponding get and put operations are performed.
There is a problem here, if the clean method runs for a long time, then the current run of the machine is hung, causing the lock element to exist on the Redis server.
After this machine restarts, the cache cannot be used normally. The reason is that when the get and put methods run, lock lock always exists on the Redis server.
This is the case when the project is running.
Summarize:
In the development process, if you use a method in the open source framework, it is important to understand how it is implemented and how to use the scenario. What is the worst case scenario.
Spring Redis Cache Usage Considerations