Distributed Lock spring boot assembly spring-boot-klock-starter
spring-boot-klock-starter
Redis distributed based on a spring boot lock assembly, with this component, the project has distributed lock capability allows easy, with support spring boot, and spirng mvc and other spring-related items.
Quick Start
spring boot project access
1. Add the lock starter component depends, yet to be uploaded to a public warehouse, needs its own source build under
2.application.properties configuration redis link: spring.klock.address = 127.0.0.1: 6379
3. On the method need to add distributed locks, add annotations @Klock, such as:
spring mvc project access
Other steps and spring boot steps as to scan only KlockAutoConfiguration based configuration spring-xx.xml added, such as:
<context:component-scan base-package="org.springframework.boot.autoconfigure.klock.KlockAutoConfiguration"/>
Use Parameter Description
Configuration Parameter Description
@Klock notes Parameter Description
@Klock can label four parameters are as follows role name: lock's name, key value corresponding to the redis. The default is: class name + method name lockType: the type of lock, currently supports (reentrant locks, fair locks, read and write locks). The default is: Fair lock waitTime: get the longest lock wait time. Default: 60s. But also can be configured through a unified spring.klock.waitTime leaseTime: After acquiring the lock, automatic lock release time. Default: 60s. But also can be configured through a unified spring.klock.leaseTime
About Test
Under the project test module, distributed lock test modules. Distributed Lock can quickly experience the effect.