Convert Figma logo to code with AI

redisson logoredisson

Redisson - Easy Redis Java client and Real-Time Data Platform. Valkey compatible. Sync/Async/RxJava/Reactive API. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, RPC, local cache ...

23,170
5,327
23,170
383

Top Related Projects

5,352

Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.

11,781

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.

9,031

Main Portal page for the Jackson project

33,257

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

  1. Creating a distributed Map:
RMap<String, String> map = redisson.getMap("myMap");
map.put("key", "value");
String value = map.get("key");
  1. Using a distributed Lock:
RLock lock = redisson.getLock("myLock");
lock.lock();
try {
    // perform locked operations
} finally {
    lock.unlock();
}
  1. 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:

  1. 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>
  1. Create a Redisson client instance:
Config config = new Config();
config.useSingleServer().setAddress("redis://127.0.0.1:6379");
RedissonClient redisson = Redisson.create(config);
  1. Use Redisson objects and services in your application:
RMap<String, String> map = redisson.getMap("myMap");
map.put("key", "value");
  1. Don't forget to shut down the Redisson client when you're done:
redisson.shutdown();

Competitor Comparisons

5,352

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.

11,781

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.

9,031

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.

33,257

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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Redisson - Easy Redis Java client
and Real-Time Data Platform

Maven Central JavaDoc License

Quick start | Documentation | Changelog | Code examples | FAQs | Report an issue

Based on high-performance async and lock-free Java Redis client and Netty framework.

Features

Comparing solutions

Redisson vs Jedis

Redisson vs Lettuce

Redis vs Apache Ignite

Redis vs Hazelcast

Redis vs Ehcache

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

Quick start

Maven

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

Gradle

compile 'org.redisson:redisson:3.35.0'  

SBT

libraryDependencies += "org.redisson" % "redisson" % "3.35.0"

Java

// 1. Create config object
Config config = new Config();
config.useClusterServers()
       // use "rediss://" for SSL connection
      .addNodeAddress("redis://127.0.0.1:7181");

// or read config from file
config = Config.fromYAML(new File("config-file.yaml")); 
// 2. Create Redisson instance

// Sync and Async API
RedissonClient redisson = Redisson.create(config);

// Reactive API
RedissonReactiveClient redissonReactive = redisson.reactive();

// RxJava3 API
RedissonRxClient redissonRx = redisson.rxJava();
// 3. Get Redis based implementation of 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. Get Redis based implementation of java.util.concurrent.locks.Lock
RLock lock = redisson.getLock("myLock");

RLockReactive lockReactive = redissonReactive.getLock("myLock");

RLockRx lockRx = redissonRx.getLock("myLock");
// 4. Get Redis based implementation of java.util.concurrent.ExecutorService
RExecutorService executor = redisson.getExecutorService("myExecutorService");

// over 50 Redis based Java objects and services ...

Upgrade to Redisson PRO with advanced features.

Downloads

Redisson 3.35.0, Redisson node 3.35.0

FAQs

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?

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?

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?