Spring Redis Cache Usage Considerations

Source: Internet
Author: User
Tags redis server

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.