redisson
Redisson - Easy Redis Java client and Real-Time Data Platform. Valkey compatible. Sync/Async/RxJava/Reactive API. Over 50 Redis or Valkey based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Spring, Tomcat, Scheduler, JCache API, Hibernate, RPC, local cache...
Top Related Projects
Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
Redis Java client
Provides support to increase developer productivity in Java when using Redis, a key-value store. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
Main Portal page for the Jackson project
Netty project - an event-driven asynchronous network application framework
Quick Overview
Redisson is a Redis client for Java with features for distributed objects and services. It offers a wide range of distributed Java objects and services, such as distributed collections, locks, and publish/subscribe messaging, all built on top of Redis. Redisson simplifies the development of distributed applications by providing a high-level API for Redis operations.
Pros
- Extensive set of distributed Java objects and services
- High-performance and thread-safe implementation
- Supports various Redis deployment models (single, sentinel, cluster)
- Automatic reconnection and retry mechanisms
Cons
- Steeper learning curve compared to simpler Redis clients
- Potential overhead for simple use cases
- Dependency on Redis for all operations
- Limited support for non-JVM languages
Code Examples
- Creating a distributed Map:
RMap<String, String> map = redisson.getMap("myMap");
map.put("key", "value");
String value = map.get("key");
- Using a distributed Lock:
RLock lock = redisson.getLock("myLock");
lock.lock();
try {
// perform locked operations
} finally {
lock.unlock();
}
- Publish/Subscribe messaging:
RTopic topic = redisson.getTopic("myTopic");
topic.addListener(String.class, (channel, message) -> {
System.out.println("Message received: " + message);
});
topic.publish("Hello, Redisson!");
Getting Started
To start using Redisson in your Java project:
- Add the Redisson dependency to your project's
pom.xml
(for Maven):
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.17.0</version>
</dependency>
- Create a Redisson client instance:
Config config = new Config();
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
RedissonClient redisson = Redisson.create(config);
- Use Redisson objects and services in your application:
RMap<String, String> map = redisson.getMap("myMap");
map.put("key", "value");
- Don't forget to shut down the Redisson client when you're done:
redisson.shutdown();
Competitor Comparisons
Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
Pros of Lettuce
- Lightweight and non-blocking, built on Netty for high performance
- Extensive support for Redis Cluster and Sentinel
- Comprehensive documentation and active community support
Cons of Lettuce
- Steeper learning curve, especially for developers new to reactive programming
- Less built-in support for distributed Java objects compared to Redisson
- Fewer high-level constructs and abstractions for complex Redis operations
Code Comparison
Lettuce:
RedisClient redisClient = RedisClient.create("redis://localhost:6379");
StatefulRedisConnection<String, String> connection = redisClient.connect();
RedisCommands<String, String> syncCommands = connection.sync();
syncCommands.set("key", "Hello, Redis!");
Redisson:
Config config = new Config();
config.useSingleServer().setAddress("redis://localhost:6379");
RedissonClient redisson = Redisson.create(config);
RBucket<String> bucket = redisson.getBucket("key");
bucket.set("Hello, Redis!");
Both libraries offer efficient ways to interact with Redis, but Redisson provides a more abstracted API with built-in support for distributed objects, while Lettuce offers a lower-level, highly performant approach with reactive programming capabilities.
Redis Java client
Pros of Jedis
- Lightweight and simple API, making it easy to learn and use
- Faster performance for basic operations due to its simplicity
- Widely adopted and well-established in the Redis community
Cons of Jedis
- Limited support for advanced Redis features and data structures
- Lacks built-in connection pooling, requiring additional configuration
- Less comprehensive documentation compared to Redisson
Code Comparison
Jedis:
Jedis jedis = new Jedis("localhost");
jedis.set("key", "value");
String value = jedis.get("key");
jedis.close();
Redisson:
RedissonClient redisson = Redisson.create();
RBucket<String> bucket = redisson.getBucket("key");
bucket.set("value");
String value = bucket.get();
redisson.shutdown();
The code examples demonstrate the basic usage of both libraries for setting and getting a key-value pair. Jedis uses a more straightforward approach with direct method calls, while Redisson utilizes distributed objects and provides a more object-oriented interface.
Redisson offers a wider range of features and abstractions, making it suitable for complex Redis operations and distributed systems. However, Jedis remains a popular choice for simpler use cases and projects that prioritize performance for basic operations.
Provides support to increase developer productivity in Java when using Redis, a key-value store. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
Pros of Spring Data Redis
- Seamless integration with Spring ecosystem
- Extensive documentation and community support
- Abstraction layer for multiple Redis clients (Lettuce, Jedis)
Cons of Spring Data Redis
- Steeper learning curve for non-Spring users
- Less feature-rich compared to Redisson's advanced functionalities
- Potentially slower performance due to abstraction layer
Code Comparison
Spring Data Redis:
@Repository
public interface UserRepository extends CrudRepository<User, String> {
User findByUsername(String username);
}
Redisson:
RMap<String, User> map = redisson.getMap("users");
User user = map.get("username");
Spring Data Redis provides a higher-level abstraction with repository interfaces, while Redisson offers more direct access to Redis data structures. Spring Data Redis is ideal for Spring-based applications, whereas Redisson provides a more flexible and feature-rich approach for Redis interactions across various Java frameworks.
Both libraries have their strengths, and the choice depends on the specific project requirements, existing technology stack, and developer preferences. Spring Data Redis excels in Spring environments, while Redisson offers more advanced Redis features and better performance in non-Spring contexts.
Main Portal page for the Jackson project
Pros of Jackson
- Widely adopted and well-established JSON processing library for Java
- Extensive support for various data formats beyond JSON (XML, YAML, CSV, etc.)
- Highly customizable with a rich ecosystem of modules and extensions
Cons of Jackson
- Steeper learning curve due to its extensive feature set
- Can be overkill for simple JSON processing tasks
- May require additional configuration for complex use cases
Code Comparison
Jackson (JSON parsing):
ObjectMapper mapper = new ObjectMapper();
MyObject obj = mapper.readValue(jsonString, MyObject.class);
Redisson (Redis operations):
RedissonClient redisson = Redisson.create();
RMap<String, String> map = redisson.getMap("myMap");
map.put("key", "value");
Key Differences
- Jackson focuses on data serialization/deserialization, while Redisson is a Redis client
- Redisson provides distributed Java objects and services, whereas Jackson is primarily for data processing
- Jackson is more versatile for general data handling, while Redisson specializes in Redis-based operations
Both libraries serve different purposes and can be complementary in a Java ecosystem. Jackson excels at data transformation, while Redisson offers robust Redis integration and distributed computing features.
Netty project - an event-driven asynchronous network application framework
Pros of Netty
- Lower-level networking framework offering more flexibility and control
- Broader application scope beyond Redis, suitable for various network protocols
- Larger community and ecosystem with extensive documentation
Cons of Netty
- Steeper learning curve due to its low-level nature
- Requires more boilerplate code for basic functionality
- Less specialized for Redis operations compared to Redisson
Code Comparison
Netty (basic server setup):
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
Redisson (Redis connection):
Config config = new Config();
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
RedissonClient redisson = Redisson.create(config);
RMap<String, String> map = redisson.getMap("myMap");
Netty provides a more general-purpose networking framework, while Redisson offers a higher-level abstraction specifically for Redis operations. Netty requires more setup but offers greater flexibility, whereas Redisson simplifies Redis interactions with a more focused API.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Redisson - Easy Redis Java client
and Real-Time Data Platform
Quick start | Documentation | Changelog | Code examples | Report an issue
High-performance async and lock-free Java client for Redis and Valkey based on Netty framework.
Features
- Thread-safe implementation
- JDK 1.8+ up to the latest version compatible
- Android compatible
- Redis compatible - from 3.0 up to the latest version
- Valkey compatible - from 7.2.5 up to the latest version
- Supported deployment types
- Amazon Web Services compatible
- Microsoft Azure compatible
- Google Cloud Memorystore compatible
- Redis Enterprise compatible
- IBM Cloud compatible
- Aiven compatible
- Supports auto-reconnection
- Supports failed to send command auto-retry
- Supports OSGi
- Supports SSL
- Asynchronous connection pool
- Lua scripting
- RediSearch
- JSON datatype
- JSON Store
- Reactive Streams API
- RxJava3 API
- Asynchronous API
- Local cache support including Caffeine-based implementation
- Cache API implementations Spring Cache, JCache API (JSR-107), Hibernate Cache, MyBatis Cache, Quarkus Cache, Micronaut Cache
- Distributed Java objects
Object holder, JSON holder, Binary stream holder, Geospatial holder, BitSet, PublishSubscribe, Bloom filter, HyperLogLog - Distributed Java counters
AtomicLong, AtomicDouble, LongAdder, DoubleAdder - Distributed Java collections
JSON Store, 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 - Microservices integration
Helidon, Micronaut, Quarkus - Integration with Spring framework
Spring Boot Starter, Spring Cache, Spring Session, Spring Transaction Manager, Spring Cloud Stream, Spring Data Redis - Web Session Management
Apache Tomcat Session, Spring Session, Micronaut Session - Transactions API
- Redis pipelining (command batches)
- Supports many popular codecs (Kryo, Jackson JSON, Avro, Smile, CBOR, MsgPack, Amazon Ion, LZ4, Snappy, Protobuf and JDK Serialization)
- 2000+ unit tests
Comparing solutions
Success stories
- Moving from Hazelcast to Redis / Datorama
- Migrating from Hazelcast to Redis / Halodoc
- Distributed Locking with Redis (Migration from Hazelcast) / ContaAzul
- Migrating from Coherence to Redis
Upgrade to Redisson PRO with advanced features.
Top Related Projects
Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
Redis Java client
Provides support to increase developer productivity in Java when using Redis, a key-value store. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
Main Portal page for the Jackson project
Netty project - an event-driven asynchronous network application framework
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot