@Target(value=METHOD) @Retention(value=RUNTIME) @Documented public @interface RedLocks
负责处理需要同时加锁多个 key 的情况
| 限定符和类型 | 必需的元素和说明 |
|---|---|
String[] |
keys
锁的 key
一条 key 中只能存在一个 spEl 表达式
类似于:
#user.userId
#user.userId:password
user:#user.userId:password
|
| 限定符和类型 | 可选元素和说明 |
|---|---|
boolean |
isFair
是否公平锁
|
long |
leaseTime
加锁的时间(单位
timeUnit()),超过这个时间后锁便自动解锁;
如果 leaseTime 为 -1,则保持锁定直到显式解锁 |
TimeUnit |
timeUnit
参数的时间单位
|
long |
waitTime
获取锁的最大尝试时间(单位
timeUnit())
该值大于 0 则使用 locker.tryLock 方法加锁,否则使用 locker.lock 方法 |
public abstract String[] keys
一条 key 中只能存在一个 spEl 表达式
类似于:
#user.userId
#user.userId:password
user:#user.userId:password
public abstract long leaseTime
timeUnit()),超过这个时间后锁便自动解锁;
如果 leaseTime 为 -1,则保持锁定直到显式解锁
public abstract TimeUnit timeUnit
public abstract long waitTime
timeUnit())
该值大于 0 则使用 locker.tryLock 方法加锁,否则使用 locker.lock 方法
Copyright © 2023 Irvingsoft. All rights reserved.