Major updates to spring-boot-klock-starter V1.1 Main Functions,

Source: Internet
Author: User

Major updates to spring-boot-klock-starter V1.1 Main Functions,

The redis-based spring-boot Distributed Lock component makes it extremely simple and out-of-the-box.

This component is also applicable to spring mvc projects.

Content of this update:

  1. Service key that supports locking method input parameters
  2. Service keys can be obtained through annotation.
  3. Support for Spel to obtain business keys

The usage is as follows:

 

Scenario Description:

This update mainly solves the problem where the value of the input parameter needs to be locked at the same time and the value of the input parameter is not locked when the value is different;

Out-of-the-box

1. Add the lock starter component dependency

<dependency>      <groupId>org.springframework.boot</groupId>      <artifactId>spring-boot-klock-starter</artifactId>      <version>1.0-SNAPSHOT</version>    </dependency>

2.application.propertiesConfigure the redis link:spring.klock.address=127.0.0.1:6379

3. Add the annotation @ Klock on the method to add the Distributed Lock, for example:

@ Servicepublic class TestService {@ Klock (waitTime = Long. MAX_VALUE) public String getValue (String param) throws Exception {if ("sleep ". equals (param) {// Thread sleep or breakpoint blocking, to achieve the test effect of staying locked. Thread. sleep (1000*50);} return "success ";}}

Summary

The above is a major update of spring-boot-klock-starter V1.1 main function introduced by Alibaba Cloud. I hope it will be helpful to you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.