public class RedisLock<T extends redis.clients.jedis.JedisCommands> extends Object
| Constructor and Description |
|---|
RedisLock() |
| Modifier and Type | Method and Description |
|---|---|
void |
lock(String key,
String request)
blocking lock
|
boolean |
lock(String key,
String request,
int blockTime)
blocking lock,custom time
|
void |
setJedis(T jedis) |
boolean |
tryLock(String key,
String request)
Non-blocking lock
|
boolean |
tryLock(String key,
String request,
int expireTime)
Non-blocking lock
|
boolean |
unlock(String key,
String request)
unlock
|
public boolean tryLock(String key, String request)
key - lock business typerequest - valuepublic void lock(String key, String request) throws InterruptedException
key - request - InterruptedExceptionpublic boolean lock(String key, String request, int blockTime) throws InterruptedException
key - request - blockTime - custom timeInterruptedExceptionpublic boolean tryLock(String key, String request, int expireTime)
key - lock business typerequest - valueexpireTime - custom expireTimepublic boolean unlock(String key, String request)
key - request - request must be the same as lock requestpublic void setJedis(T jedis)
Copyright © 2018. All rights reserved.