快速开始 | 文档 | 变更日志 | 代码示例 | 常见问题 | 报告问题
基于高性能异步无锁Java Redis客户端和 Netty 框架。
JDK 兼容性:1.8 - 16,Android
- Redis 复制设置 (包括支持 AWS ElastiCache 和 Azure Redis Cache)
- Redis 集群设置 (包括支持 AWS ElastiCache Cluster 和 Azure Redis Cache)
- Redis 哨兵设置
- Redis with Master with Slave only
- Redis single (包括支持 Azure Redis Cache 和 Google Cloud Memorystore for Redis)
- 线程安全的实现
- Reactive Streams API
- RxJava3 API
- Asynchronous API
- 异步连接池
- Lua 脚本
- 本地缓存支持包括 Caffeine -基于实现
- Distributed Java objects
Object holder, Binary stream holder, Geospatial holder, BitSet, AtomicLong, AtomicDouble, PublishSubscribe, Bloom filter, HyperLogLog - Distributed Java collections
Map, Multimap, Set, List, SortedSet, ScoredSortedSet, LexSortedSet, Queue, Deque, Blocking Queue, Bounded Blocking Queue, Blocking Deque, Delayed Queue, Priority Queue, Priority Deque - Distributed Java locks and synchronizers
Lock, FairLock, MultiLock, RedLock, ReadWriteLock, Semaphore, PermitExpirableSemaphore, CountDownLatch - Distributed services
Remote service, Live Object service, Executor service, Scheduler service, MapReduce service - Helidon 整合
- Micronaut 整合
- Quarkus 整合
- Spring Cache 实现
- Spring Transaction API 实现
- Spring Data Redis 整合
- Spring Boot Starter 实现
- Hibernate Cache 实现
- MyBatis Cache 实现
- Transactions API
- JCache API (JSR-107) 实现
- Tomcat Session Manager 实现
- Spring Session 实现
- Redis pipelining (command batches)
- 支持安卓平台
- 支持自动重连
- 支持发送命令失败自动重试
- 支持 OSGi
- 支持 SSL
- 支持许多流行的编解码器 (JBoss Marshalling, Jackson JSON, Avro, Smile, CBOR, MsgPack, Kryo, Amazon Ion, LZ4, Snappy 和 JDK 序列化)
- 超过 2000 个单元测试
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.16.1</version>
</dependency>
compile 'org.redisson:redisson:3.16.1'
libraryDependencies += "org.redisson" % "redisson" % "3.16.1"
// 1. 创建配置对象
Config config = new Config();
config.useClusterServers()
// 使用“rediss:”进行 SSL 连接
.addNodeAddress("redis://127.0.0.1:7181");
// 或从文件中读取配置
config = Config.fromYAML(new File("config-file.yaml"));
// 2. 创建Redisson实例
// Sync and Async API
RedissonClient redisson = Redisson.create(config);
// Reactive API
RedissonReactiveClient redissonReactive = redisson.reactive();
// RxJava3 API
RedissonRxClient redissonRx = redisson.rxJava();
// 3. 获取基于 Redis 的 java.util.concurrent.ConcurrentMap 实现
RMap<MyKey, MyValue> map = redisson.getMap("myMap");
RMapReactive<MyKey, MyValue> mapReactive = redissonReactive.getMap("myMap");
RMapRx<MyKey, MyValue> mapRx = redissonRx.getMap("myMap");
// 4. 获取基于 Redis 的 java.util.concurrent.locks.Lock 实现
RLock lock = redisson.getLock("myLock");
RLockReactive lockReactive = redissonReactive.getLock("myLock");
RLockRx lockRx = redissonRx.getLock("myLock");
// 4. 获取基于 Redis 的 java.util.concurrent.ExecutorService 实现
RExecutorService executor = redisson.getExecutorService("myExecutorService");
// over 50 Redis based Java objects and services ...
考虑 Redisson PRO 版本以获得超快的性能和 SLA 支持。
Redisson 3.16.1, Redisson node 3.16.1
Q: What is the cause of RedisTimeoutException?
Q: How can I perform Pipelining/Transaction through Redisson?
Q: Is Redisson thread safe? Can I share an instance of it between different threads?
Q: Can I use different encoder/decoders for different tasks?