Java Data Structures Powered by - Introduction To: Redis Redisson
Java Data Structures Powered by - Introduction To: Redis Redisson
Java Data Structures Powered by - Introduction To: Redis Redisson
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
set.add("value");
set.contains("value");
set.remove("value");
REDISSON BLOCKINGQUEUE
set.add(new MyObj("value"));
MyObj obj = queue.peek();
MyObj obj = queue.poll(10, TimeUnit.MINUTES);
DISTRIBUTED LOCKS
AND SYNCHRONIZERS
▸ Lock
▸ FairLock
▸ RedLock
▸ MultiLock
▸ ReadWriteLock
▸ Semaphore
▸ PermitExpirableSemaphore
▸ CountDownLatch
▸ Phaser (Planned)
REDISSON LOCK
lock.lock();
// or
lock.lock(10, TimeUnit.MINUTES);
//…
lock.unlock();
DISTRIBUTED OBJECTS
▸ Replicated nodes *
▸ Cluster nodes *
▸ Sentinel nodes
▸ Master with Slave nodes
▸ Single node
▸ Jackson JSON
▸ Avro
▸ Smile
▸ CBOR
▸ MsgPack
▸ Snappy
▸ Kryo
▸ FST
▸ LZ4
▸ JDK Serialization
HOW TO START
// 1. Create config object
Config = new Config();
config.useClusterServers()
.addNodeAddress("myserver.com:7000", "myserver.com:7001");
// 2. Create Redisson instance
RedissonClient redisson = Redisson.create(config);
// 3. Get object you need
Map<String, String> map = redisson.getMap("myMap");
ASYNCHRONOUS
COMMAND EXECUTION
RMapAsync<Integer, String> map = redisson.getMap("someMap");
Future<String> putIfFuture = map.putIfAbsentAsync(20, "object");
Future<String> getFuture = map.getAsync(20);
getFuture.addListener(new FutureListener<Boolean>() {
@Override
public void operationComplete(Future<Boolean> future)
throws Exception {
//…
}
});
REACTIVE
COMMAND EXECUTION
conn.sync(StringCodec.INSTANCE,
RedisCommands.SET, "key", "value");
http://redisson.org