redisson 应用(三)

Lock 锁

Semaphore 信号量

CountDownLatch 栅栏

远程服务调用

Redisson 提供了一种远程服务调用的方式。

RRemoteService remoteService = redisson.getRemoteService();
SomeServiceImpl someServiceImpl = new SomeServiceImpl();

// 注册服务
// 同一时间只处理一个调用
remoteService.register(SomeServiceInterface.class, someServiceImpl);

// 设置可以并发调用的连接数
remoteService.register(SomeServiceInterface.class, someServiceImpl, 12);
RRemoteService remoteService = redisson.getRemoteService();
SomeServiceInterface service = remoteService.get(SomeServiceInterface.class);

String result = service.doSomeStuff(1L, "secondParam", new AnyParam());

可以注册多个服务实例,对于服务调用,现在不清楚负载均衡等细节。

Live Object service

提供了各种查询操作,可以当做类似文档数据库使用。

Distributed executor service

分布式 executor service ,相当于Java ExecutorService的分布式版本。在执行分布式计算的时候很方便。

你可能感兴趣的:(redisson 应用(三))