Redission 实现 Redis 分布式锁

Maven

<dependency>  
   <groupId>org.redisson</groupId>
   <artifactId>redisson</artifactId>
   <version>2.3.0</version>
</dependency>  

Java

// 1. Create config object
Config = ...

// 2. Create Redisson instance
RedissonClient redisson = Redisson.create(config);

// 3. Get object you need
RMap<MyKey, MyValue> map = redisson.getMap("myMap");

RLock lock = redisson.getLock("myLock");

RExecutorService executor = redisson.getExecutorService("myExecutorService");

// over 30 different objects and services ...
参考