0% found this document useful (0 votes)
91 views22 pages

Introduction to Redisson for Java

This document introduces Redisson, an open source Redis client that provides advanced features like distributed collections, locks, and synchronization primitives. It allows developers to use Redis to power distributed Java and JVM-based applications. Redisson supports various connection modes to Redis and data serialization formats. It also integrates with frameworks like Spring and provides both blocking and reactive APIs for asynchronous command execution.

Uploaded by

tejpremium
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views22 pages

Introduction to Redisson for Java

This document introduces Redisson, an open source Redis client that provides advanced features like distributed collections, locks, and synchronization primitives. It allows developers to use Redis to power distributed Java and JVM-based applications. Redisson supports various connection modes to Redis and data serialization formats. It also integrates with frameworks like Spring and provides both blocking and reactive APIs for asynchronous command execution.

Uploaded by

tejpremium
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
  • Introduction to Redisson
  • Why Redisson?
  • Community Oriented
  • Distributed Collections
  • Map Implementation
  • Redisson Map
  • Redisson Map Eviction
  • Redisson Set
  • Redisson BlockingQueue
  • Distributed Locks and Synchronizers
  • Redisson Lock
  • Distributed Objects
  • Redisson Pub/Sub
  • Integration with Frameworks
  • Connection Modes
  • Data Serialization
  • How to Start
  • Asynchronous Command Execution
  • Reactive Command Execution
  • Low-Level Redis Client
  • Companies Using Redisson
  • Conclusion

Java data structures

powered by Redis.
Introduction to
Redisson

Nikita Koksharov
Founder of
WHY REDISSON? WHY DO WE
NEED ANOTHER REDIS CLIENT?
COMMUNITY ORIENTED
OPEN SOURCE (APACHE LICENCE)
DISTRIBUTED COLLECTIONS
▸ Map * ▸ Queue
▸ MultiMap * ▸ Deque
▸ LocalCachedMap ▸ BlockingQueue
▸ Set * ▸ BlockingDeque
▸ SortedSet ▸ BoundedBlockingQueue
▸ ScoredSortedSet ▸ BlockingFairQueue
▸ LexSortedSet ▸ DelayedQueue
▸ List
* Supports individual element eviction
MAP

ConcurrentMap<Integer, MyObject> map = new ConcurrentHashMap<>();

[Link](20, new MyObject("oldobj"));


[Link](20, new MyObject("newobj"));
[Link](1);
REDISSON MAP

ConcurrentMap<Integer, MyObject> map = [Link]("someMap");

[Link](20, new MyObject("oldobj"));


[Link](20, new MyObject("newobj"));
[Link](1);
REDISSON MAP EVICTION

RMapCache<Integer, String> map = [Link]("someMap");

[Link](20, "oldobj", 20, [Link]);


[Link](4);
[Link](2, "oldobj", 5, [Link]);
REDISSON SET

Set<String> set = [Link]("someSet");

[Link]("value");
[Link]("value");
[Link]("value");
REDISSON BLOCKINGQUEUE

BlockingQueue<MyObj> queue = [Link]("someSet");

[Link](new MyObj("value"));
MyObj obj = [Link]();
MyObj obj = [Link](10, [Link]);
DISTRIBUTED LOCKS
AND SYNCHRONIZERS
▸ Lock
▸ FairLock
▸ RedLock
▸ MultiLock
▸ ReadWriteLock
▸ Semaphore
▸ PermitExpirableSemaphore
▸ CountDownLatch
▸ Phaser (Planned)
REDISSON LOCK

RLock lock = [Link]("lock");

[Link]();
// or
[Link](10, [Link]);
//…
[Link]();
DISTRIBUTED OBJECTS

▸ Bucket (Object Holder)


▸ BinaryStream (Input & Output Stream)
▸ Geo (Geospatial Object Holder)
▸ BitSet
▸ AtomicLong
▸ AtomicDouble
▸ Topic (Pub/Sub)
▸ BloomFilter
▸ HyperLogLog
REDISSON PUB/SUB
RTopic<SomeMessage> topic = [Link]("someTopic");
[Link](new MessageListener<SomeMessage>() {
@Override
public void onMessage(String channel, SomeMessage message) {
[Link](message);
}
});

// in other thread or other JVM


RTopic<SomeMessage> topic = [Link](" someTopic");
[Link](new SomeMessage("new message"));
INTERGRATION WITH
FRAMEWORKS
▸ Spring Cache
▸ Hibernate Cache
▸ JCache API (JSR-107) implementation
▸ Tomcat Session Manager
▸ Spring Session
CONNECTION MODES

▸ Replicated nodes *
▸ Cluster nodes *
▸ Sentinel nodes
▸ Master with Slave nodes
▸ Single node

* Also supports AWS ElastiCache and Azure Redis Cache


DATA SERIALIZATION

▸ Jackson JSON
▸ Avro
▸ Smile
▸ CBOR
▸ MsgPack
▸ Snappy
▸ Kryo
▸ FST
▸ LZ4
▸ JDK Serialization
HOW TO START
// 1. Create config object
Config = new Config();
[Link]()
.addNodeAddress("[Link]", "[Link]");
// 2. Create Redisson instance
RedissonClient redisson = [Link](config);
// 3. Get object you need
Map<String, String> map = [Link]("myMap");
ASYNCHRONOUS
COMMAND EXECUTION
RMapAsync<Integer, String> map = [Link]("someMap");
Future<String> putIfFuture = [Link](20, "object");
Future<String> getFuture = [Link](20);

[Link](new FutureListener<Boolean>() {
@Override
public void operationComplete(Future<Boolean> future)
throws Exception {
//…
}
});
REACTIVE
COMMAND EXECUTION

RedissonReactive redisson = [Link](config);


RMapReactive<Integer, String> map = [Link]("someMap");
Publisher<String> putRes = [Link](20, "object");
Publisher<String> value = [Link](20);
LOW-LEVEL REDIS CLIENT

RedisClient client = new RedisClient("localhost", 6379);


RedisConnection conn = [Link]();

Future<RedisConnection> connFuture = [Link]();

[Link]([Link],
[Link], "key", "value");

Future<String> res = [Link]([Link],


[Link], "key");
USED BY
▸ Electronic Arts ▸ Ocous
▸ Baidu ▸ Invaluable
▸ Infor ▸ Clover
▸ New Relic Synthetics ▸ Apache Karaf Decanter
▸ Singtel ▸ Atmosphere Framework
▸ Crimson Hexagon ▸ BrandsEye
▸ Brookhaven National ▸ Datorama
Laboratory ▸ BrightCloud
▸ Netflix Dyno client ▸ Azar
▸ 武林Q传 ▸ Snapfish
▸ Monits …
THANK YOU!

[Link]

Java data structures 
powered by Redis. 
Introduction to 
Redisson
Nikita Koksharov
Founder of
WHY REDISSON? WHY DO WE 
NEED ANOTHER REDIS CLIENT?
COMMUNITY ORIENTED
OPEN SOURCE (APACHE LICENCE)
DISTRIBUTED COLLECTIONS
▸Map *
▸MultiMap *
▸LocalCachedMap
▸Set *
▸SortedSet
▸ScoredSortedSet
▸LexSortedSet
▸List
* Supports
MAP
ConcurrentMap<Integer, MyObject> map = new ConcurrentHashMap<>();
map.put(20, new MyObject("oldobj"));
map.putIfAbsent(20
REDISSON MAP
ConcurrentMap<Integer, MyObject> map = redisson.getMap("someMap");
map.put(20, new MyObject("oldobj"));
map.putI
REDISSON MAP EVICTION
RMapCache<Integer, String> map = redisson.getMapCache("someMap");
map.put(20, "oldobj", 20, TimeUnit.MI
REDISSON SET
Set<String> set = redisson.getSet("someSet");
set.add("value");
set.contains("value");
set.remove("value");
REDISSON BLOCKINGQUEUE
BlockingQueue<MyObj> queue = redisson.getSet("someSet");
set.add(new MyObj("value"));
MyObj obj = queu
DISTRIBUTED LOCKS 
AND SYNCHRONIZERS
▸Lock
▸FairLock
▸RedLock
▸MultiLock
▸ReadWriteLock
▸Semaphore
▸PermitExpirableSemaphore

You might also like