Skip to content

Latest commit

 

History

History
57 lines (51 loc) · 2.16 KB

README.md

File metadata and controls

57 lines (51 loc) · 2.16 KB

It's a Lettuce client implementation of RedPulsar library

Getting started

Creating client is simple as:

// Create Lettuce Pooled Client
val poolConfig = GenericObjectPoolConfig<StatefulRedisConnection<String, String>>()
val client =  LettucePooled(poolConfig) { RedisClient.create("redis://localhost:6379").connect() }

Or if you need Pub/Sub support:

// Create Lettuce Pooled Pub/Sub Client
val poolConfig = GenericObjectPoolConfig<StatefulRedisConnection<String, String>>()
val pubSubClient = LettucePubSubPooled(poolConfig) { RedisClient.create("redis://localhost:6379").connectPubSub() }

Creating lock:

// Create lock
val lock = LockFactory.createSimplifiedMutex(client)
lock.lock("myResource", Duration.ofSeconds(1))
// do something
lock.unlock("myResource")

Getting started with Java

// Create Lettuce Pooled Client
var client = RedisClient.create("redis://localhost:6379");
var poolConfig = new GenericObjectPoolConfig<StatefulRedisConnection<String, String>>();
var lettucePooled = new LettucePooled<>(poolConfig, client::connect);

Or if you need Pub/Sub support:

// Create Lettuce Pooled Pub/Sub Client
var client = RedisClient.create("redis://localhost:6379");
var poolConfig = new GenericObjectPoolConfig<StatefulRedisPubSubConnection<String, String>>();
var lettucePubSubPooled = new LettucePubSubPooled<>(poolConfig, client::connectPubSub);

Creating lock:

// Create lock
var lock = LockFactory.createSimplifiedMutex(lettucePooled, Duration.ofSeconds(1), 3);
lock.lock("myResource", Duration.ofSeconds(1));
// do something
lock.unlock("myResource");

Lettuce pooled

This module provides Lettuce pooled client that simplify connection management. Instead of creating new connection each time or manage connection pool manually you can use this module.

Available options:

Both clients support synchronous, asynchronous and reactive APIs.