You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
redisson/README.md

228 lines
15 KiB
Markdown

10 months ago
# Redisson - Easy Redis Java client<br/>and Real-Time Data Platform
4 years ago
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.redisson/redisson/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.redisson/redisson)
[![JavaDoc](http://www.javadoc.io/badge/org.redisson/redisson.svg)](http://www.javadoc.io/doc/org.redisson/redisson)
[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
6 years ago
4 years ago
[Quick start](https://github.com/redisson/redisson#quick-start) | [Documentation](https://github.com/redisson/redisson/wiki/Table-of-Content) | [Changelog](https://github.com/redisson/redisson/blob/master/CHANGELOG.md) | [Code examples](https://github.com/redisson/redisson-examples) | [FAQs](https://github.com/redisson/redisson/wiki/16.-FAQ) | [Report an issue](https://github.com/redisson/redisson/issues/new)
9 years ago
9 years ago
Based on high-performance async and lock-free Java Redis client and [Netty](http://netty.io) framework.
9 months ago
9 years ago
6 years ago
## Features
9 months ago
* Thread-safe implementation
7 months ago
* JDK 1.8+ compatible
* Android compatible
* [Redis](https://redis.io) 3.0 - 7.4 compatible
9 months ago
* [Valkey](https://valkey.io) 7.2.5+ compatible
9 months ago
* Supported deployment types
9 months ago
* [Proxy](https://github.com/redisson/redisson/wiki/2.-Configuration/#29-proxy-mode)
* [Multi-Cluster](https://github.com/redisson/redisson/wiki/2.-Configuration/#210-multi-cluster-mode)
* [Multi-Sentinel](https://github.com/redisson/redisson/wiki/2.-Configuration/#211-multi-sentinel-mode)
* [Single](https://github.com/redisson/redisson/wiki/2.-Configuration/#26-single-instance-mode)
* [Cluster](https://github.com/redisson/redisson/wiki/2.-Configuration/#24-cluster-mode)
* [Sentinel](https://github.com/redisson/redisson/wiki/2.-Configuration/#27-sentinel-mode)
* [Replicated](https://github.com/redisson/redisson/wiki/2.-Configuration/#25-replicated-mode)
* [Master and Slaves](https://github.com/redisson/redisson/wiki/2.-Configuration/#28-master-slave-mode)
2 years ago
* Amazon Web Services compatible
9 months ago
* [AWS Elasticache Serverless](https://aws.amazon.com/elasticache/features/#Serverless)
2 years ago
* [AWS Redis Global Datastore](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Redis-Global-Datastore.html)
* [AWS ElastiCache](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/WhatIs.html)
* [Amazon MemoryDB](https://aws.amazon.com/memorydb)
2 years ago
* Microsoft Azure compatible
2 years ago
* [Azure Redis Cache](https://azure.microsoft.com/en-us/services/cache/)
* [Azure Redis Cache active-passive replication](https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-how-to-geo-replication)
2 years ago
* [Azure Redis Cache active-active replication](https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-how-to-active-geo-replication)
2 years ago
* Google Cloud Memorystore compatible
2 years ago
* [Google Cloud Redis](https://cloud.google.com/memorystore/docs/redis/)
* [Google Cloud Redis High availability](https://cloud.google.com/memorystore/docs/redis/high-availability)
2 years ago
* Redis Enterprise compatible
2 years ago
* [Redis Enterprise](https://redis.com/redis-enterprise/)
* [Redis Enterprise Active-Active databases](https://docs.redis.com/latest/rs/databases/active-active/get-started/)
* [Redis Enterprise Multiple Active Proxy](https://docs.redis.com/latest/rs/databases/configure/proxy-policy/#about-multiple-active-proxy-support)
2 years ago
* IBM Cloud compatible
* [IBM Cloud Databases for Redis](https://www.ibm.com/cloud/databases-for-redis)
2 years ago
* Aiven compatible
* [Aiven for Redis](https://aiven.io/redis)
2 years ago
* Supports auto-reconnection
* Supports failed to send command auto-retry
* Supports OSGi
* Supports SSL
* Asynchronous connection pool
* Lua scripting
2 years ago
* [RediSearch](https://github.com/redisson/redisson/wiki/9.-distributed-services/#96-redisearch-service)
3 years ago
* [JSON datatype](https://github.com/redisson/redisson/wiki/6.-distributed-objects/#615-json-object-holder)
7 months ago
* [JSON Store](https://github.com/redisson/redisson/wiki/7.-distributed-collections/#724-json-store)
8 years ago
* [Reactive Streams](https://github.com/redisson/redisson/wiki/3.-operations-execution#32-reactive-way) API
4 years ago
* [RxJava3](https://github.com/redisson/redisson/wiki/3.-operations-execution#32-reactive-way) API
8 years ago
* [Asynchronous](https://github.com/redisson/redisson/wiki/3.-operations-execution#31-async-way) API
5 years ago
* Local cache support including [Caffeine](https://github.com/ben-manes/caffeine)-based implementation
6 years ago
* [Distributed Java objects](https://github.com/redisson/redisson/wiki/6.-Distributed-objects)
8 years ago
Object holder, Binary stream holder, Geospatial holder, BitSet, AtomicLong, AtomicDouble, PublishSubscribe,
Bloom filter, HyperLogLog
6 years ago
* [Distributed Java collections](https://github.com/redisson/redisson/wiki/7.-Distributed-collections)
Map, Multimap, Set, List, SortedSet, ScoredSortedSet, LexSortedSet, Queue, Deque, Blocking Queue, Bounded Blocking Queue, Blocking Deque, Delayed Queue, Priority Queue, Priority Deque
6 years ago
* [Distributed Java locks and synchronizers](https://github.com/redisson/redisson/wiki/8.-Distributed-locks-and-synchronizers)
8 years ago
Lock, FairLock, MultiLock, RedLock, ReadWriteLock, Semaphore, PermitExpirableSemaphore, CountDownLatch
8 years ago
* [Distributed services](https://github.com/redisson/redisson/wiki/9.-distributed-services)
8 years ago
Remote service, Live Object service, Executor service, Scheduler service, MapReduce service
4 years ago
* [Helidon](https://github.com/redisson/redisson/tree/master/redisson-helidon) integration
* [Micronaut](https://github.com/redisson/redisson/tree/master/redisson-micronaut) integration
* [Quarkus](https://github.com/redisson/redisson/tree/master/redisson-quarkus) integration
5 years ago
* [Spring Cache](https://github.com/redisson/redisson/wiki/14.-Integration-with-frameworks/#142-spring-cache) implementation
9 months ago
* [Spring Cloud Stream](https://github.com/redisson/redisson/wiki/14.-Integration-with-frameworks/#149-spring-cloud-stream) implementation
5 years ago
* [Spring Transaction API](https://github.com/redisson/redisson/wiki/14.-Integration-with-frameworks/#148-spring-transaction-manager) implementation
9 months ago
* [Spring Data Redis](https://github.com/redisson/redisson/tree/master/redisson-spring-data) implementation
5 years ago
* [Spring Boot Starter](https://github.com/redisson/redisson/tree/master/redisson-spring-boot-starter) implementation
5 years ago
* [Hibernate Cache](https://github.com/redisson/redisson/tree/master/redisson-hibernate) implementation
* [MyBatis Cache](https://github.com/redisson/redisson/tree/master/redisson-mybatis) implementation
7 years ago
* [Transactions API](https://github.com/redisson/redisson/wiki/10.-Additional-features#104-transactions)
5 years ago
* [JCache API (JSR-107)](https://github.com/redisson/redisson/wiki/14.-Integration-with-frameworks/#144-jcache-api-jsr-107-implementation) implementation
5 years ago
* [Tomcat Session Manager](https://github.com/redisson/redisson/tree/master/redisson-tomcat) implementation
5 years ago
* [Spring Session](https://github.com/redisson/redisson/wiki/14.-Integration-with-frameworks/#147-spring-session) implementation
* [Redis pipelining](https://github.com/redisson/redisson/wiki/10.-additional-features#103-execution-batches-of-commands) (command batches)
11 months ago
* Supports many popular codecs ([Kryo](https://github.com/EsotericSoftware/kryo), [Jackson JSON](https://github.com/FasterXML/jackson), [Avro](http://avro.apache.org/), [Smile](http://wiki.fasterxml.com/SmileFormatSpec), [CBOR](http://cbor.io/), [MsgPack](http://msgpack.org/), [Amazon Ion](https://amzn.github.io/ion-docs/), [LZ4](https://github.com/jpountz/lz4-java), [Snappy](https://github.com/xerial/snappy-java), [Protobuf](https://github.com/protocolbuffers/protobuf) and JDK Serialization)
11 months ago
* 2000+ unit tests
6 years ago
<!--
8 years ago
Used by
10 years ago
================================
7 years ago
[![Siemens](https://redisson.org/assets/logos/client29.png "Siemens")](https://www.siemens.com) &nbsp;&nbsp;&nbsp;
[![BMW GROUP](https://redisson.org/assets/logos/client27.png "BMW GROUP")](https://www.bmwgroup.com) &nbsp;&nbsp;&nbsp;
7 years ago
[![AIG](https://redisson.org/assets/logos/client24.png "AIG")](https://www.aig.com/) &nbsp;&nbsp;&nbsp;
7 years ago
[![S&P Global](https://redisson.org/assets/logos/client20.png "S&P Global")](https://www.spglobal.com/) &nbsp;&nbsp;&nbsp;
8 years ago
[![SAP](https://redisson.org/assets/logos/client12.png "SAP")](http://www.sap.com/) &nbsp;&nbsp;&nbsp;
7 years ago
[![EA](https://redisson.org/assets/logos/client1.png "EA")](http://ea.com/) &nbsp;&nbsp;&nbsp;
[![Adobe](https://redisson.org/assets/logos/client23.png "Adobe")](https://www.adobe.com/)
7 years ago
7 years ago
[![Jeppesen](https://redisson.org/assets/logos/client25.png "Jeppesen")](https://www.jeppesen.com/) &nbsp;&nbsp;&nbsp;
[![BROOKHAVEN](https://redisson.org/assets/logos/client6.png "Brookhaven National Laboratory")](http://bnl.gov/) &nbsp;&nbsp;&nbsp;
[![New Relic Synthetics](https://redisson.org/assets/logos/client3.png "New Relic Synthetics")](http://newrelic.com/synthetics) &nbsp;&nbsp;&nbsp;
7 years ago
[![Netflix](https://redisson.org/assets/logos/client10.png "Netflix")](https://netflix.com/) &nbsp;&nbsp;&nbsp;
7 years ago
[![Personal Capital](https://redisson.org/assets/logos/client26.png "Personal Capital")](https://www.personalcapital.com)
[![Singtel](https://redisson.org/assets/logos/client5.png "New Relic Synthetics")](http://singtel.com/) &nbsp;&nbsp;&nbsp;
7 years ago
[![Baidu](https://redisson.org/assets/logos/client2.png "Baidu")](http://baidu.com/) &nbsp;&nbsp;&nbsp;
8 years ago
[![Infor](https://redisson.org/assets/logos/client4.png "Infor")](http://www.infor.com/) &nbsp;&nbsp;&nbsp;
7 years ago
[![Crimson Hexagon](https://redisson.org/assets/logos/client7.png "Crimson Hexagon")](https://www.crimsonhexagon.com/) &nbsp;&nbsp;&nbsp;
[![ContaAzul](https://redisson.org/assets/logos/client18.png "ContaAzul")](https://contaazul.com/)&nbsp;&nbsp;&nbsp;
[![马蜂窝](https://redisson.org/assets/logos/client33.png "马蜂窝")](http://www.mafengwo.cn/)
7 years ago
7 years ago
[![Datorama](https://redisson.org/assets/logos/client8.png "Datorama")](https://datorama.com/)&nbsp;&nbsp;&nbsp;
7 years ago
[![Ticketmaster](https://redisson.org/assets/logos/client14.png "Ticketmaster")](http://www.ticketmaster.com/)&nbsp;&nbsp;&nbsp;
7 years ago
[![NAB](https://redisson.org/assets/logos/client11.png "NAB")](https://www.nab.com.au/)&nbsp;&nbsp;&nbsp;
[![Juniper](https://redisson.org/assets/logos/client31.png "Juniper")](https://www.juniper.net/)&nbsp;&nbsp;&nbsp;
[![火币](https://redisson.org/assets/logos/client32.png "火币")](https://www.huobi.com/)&nbsp;&nbsp;&nbsp;
7 years ago
7 years ago
[![Alibaba](https://redisson.org/assets/logos/client19.png "Alibaba")](http://www.alibaba-inc.com)&nbsp;&nbsp;&nbsp;
7 years ago
[![Flipkart](https://redisson.org/assets/logos/client21.png "Flipkart")](https://www.flipkart.com/)&nbsp;&nbsp;&nbsp;
7 years ago
[![Invaluable](https://redisson.org/assets/logos/client13.png "Invaluable")](http://www.invaluable.com/)&nbsp;&nbsp;&nbsp;
7 years ago
[![BBK](https://redisson.org/assets/logos/client22.png "BBK")](http://www.gdbbk.com/)
[![SULAKE](https://redisson.org/assets/logos/client17.png "SULAKE")](http://www.sulake.com/)
7 years ago
6 years ago
<sub>Logos, product names and all other trademarks displayed on this page belong to their respective holders and used for identification purposes only. Use of these trademarks, names and brands does not imply endorsement.</sub>
6 years ago
-->
1 year ago
## Comparing solutions
### [Redisson vs Jedis](https://redisson.org/feature-comparison-redisson-vs-jedis.html)
### [Redisson vs Lettuce](https://redisson.org/feature-comparison-redisson-vs-lettuce.html)
### [Redis vs Apache Ignite](https://redisson.org/feature-comparison-redis-vs-ignite.html)
### [Redis vs Hazelcast](https://redisson.org/feature-comparison-redis-vs-hazelcast.html)
### [Redis vs Ehcache](https://redisson.org/feature-comparison-redis-vs-ehcache.html)
1 year ago
6 years ago
## Success stories
8 years ago
### [Moving from Hazelcast to Redis / Datorama](https://engineering.datorama.com/moving-from-hazelcast-to-redis-b90a0769d1cb)
### [Migrating from Hazelcast to Redis / Halodoc](https://blogs.halodoc.io/why-and-how-we-move-from-hazelcast-to-redis-2/)
### [Distributed Locking with Redis (Migration from Hazelcast) / ContaAzul](https://carlosbecker.com/posts/distributed-locks-redis/)
### [Migrating from Coherence to Redis](https://www.youtube.com/watch?v=JF5R2ucKTEg)
7 years ago
8 years ago
6 years ago
## Quick start
11 years ago
9 years ago
#### Maven
8 years ago
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
6 months ago
<version>3.34.1</version>
8 years ago
</dependency>
11 years ago
9 years ago
#### Gradle
6 months ago
compile 'org.redisson:redisson:3.34.1'
10 years ago
#### SBT
6 months ago
libraryDependencies += "org.redisson" % "redisson" % "3.34.1"
9 years ago
#### Java
```java
// 1. Create config object
6 years ago
Config config = new Config();
config.useClusterServers()
// use "rediss://" for SSL connection
.addNodeAddress("redis://127.0.0.1:7181");
9 years ago
6 years ago
// or read config from file
config = Config.fromYAML(new File("config-file.yaml"));
```
```java
9 years ago
// 2. Create Redisson instance
6 years ago
// Sync and Async API
9 years ago
RedissonClient redisson = Redisson.create(config);
6 years ago
// Reactive API
4 years ago
RedissonReactiveClient redissonReactive = redisson.reactive();
6 years ago
4 years ago
// RxJava3 API
RedissonRxClient redissonRx = redisson.rxJava();
6 years ago
```
```java
5 years ago
// 3. Get Redis based implementation of java.util.concurrent.ConcurrentMap
9 years ago
RMap<MyKey, MyValue> map = redisson.getMap("myMap");
6 years ago
RMapReactive<MyKey, MyValue> mapReactive = redissonReactive.getMap("myMap");
RMapRx<MyKey, MyValue> mapRx = redissonRx.getMap("myMap");
```
```java
5 years ago
// 4. Get Redis based implementation of java.util.concurrent.locks.Lock
9 years ago
RLock lock = redisson.getLock("myLock");
9 years ago
6 years ago
RLockReactive lockReactive = redissonReactive.getLock("myLock");
RLockRx lockRx = redissonRx.getLock("myLock");
```
```java
5 years ago
// 4. Get Redis based implementation of java.util.concurrent.ExecutorService
9 years ago
RExecutorService executor = redisson.getExecutorService("myExecutorService");
9 years ago
5 years ago
// over 50 Redis based Java objects and services ...
9 years ago
```
9 years ago
2 years ago
Upgrade to __[Redisson PRO](https://redisson.pro)__ with **advanced features**.
6 years ago
6 years ago
## Downloads
7 years ago
6 months ago
[Redisson 3.34.1](https://repo1.maven.org/maven2/org/redisson/redisson/3.34.1/redisson-3.34.1.jar),
[Redisson node 3.34.1](https://repo1.maven.org/maven2/org/redisson/redisson-all/3.34.1/redisson-all-3.34.1.jar)
7 years ago
6 years ago
## FAQs
4 years ago
[Q: What is the cause of RedisTimeoutException?](https://github.com/redisson/redisson/wiki/16.-FAQ#q-what-is-the-cause-of-redistimeoutexception)
[Q: When do I need to shut down a Redisson instance, at the end of each request or the end of the life of a thread?](https://github.com/redisson/redisson/wiki/16.-FAQ#q-when-do-i-need-to-shut-down-a-redisson-instance-at-the-end-of-each-request-or-the-end-of-the-life-of-a-thread)
6 years ago
[Q: In MapCache/SetCache/SpringCache/JCache, I have set an expiry time to an entry, why is it still in Redis when it should be disappeared?](https://github.com/redisson/redisson/wiki/16.-FAQ#q-in-mapcachesetcachespringcachejcache-i-have-set-an-expiry-time-to-an-entry-why-is-it-still-in-redis-when-it-should-be-disappeared)
[Q: How can I perform Pipelining/Transaction through Redisson?](https://github.com/redisson/redisson/wiki/16.-FAQ#q-how-can-i-perform-pipeliningtransaction-through-redisson)
[Q: Is Redisson thread safe? Can I share an instance of it between different threads?](https://github.com/redisson/redisson/wiki/16.-FAQ#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?](https://github.com/redisson/redisson/wiki/16.-FAQ#q-can-i-use-different-encoderdecoders-for-different-tasks)