pull/6220/head
Nikita Koksharov 4 months ago
parent 4d65de66a8
commit 7019e51fb8

@ -35,7 +35,11 @@ future.thenAccept(res -> {
}); });
``` ```
Avoid to use blocking methods in future listeners. Listeners executed by netty-threads and delays in listeners may cause errors in Redis or Valkey request/response processing. Use follow methods to execute blocking methods in listeners:
!!! note
Avoid using blocking methods in RFuture listeners. Listeners executed by netty-threads and delays in listeners may cause errors in Redis or Valkey request/response processing.
Use the following methods to execute blocking methods in listeners:
```java ```java
future.whenCompleteAsync((res, exception) -> { future.whenCompleteAsync((res, exception) -> {
@ -105,17 +109,21 @@ Settings above can be overridden per Redisson object instance. These settings ap
Here is an example with `RBucket` object: Here is an example with `RBucket` object:
```java ```java
Config config = new Config();
config.useSingleServer()
.setRetryAttempts(2)
.setRetryInterval(1800)
.setTimeout(5000)
.setAddress("redis://127.0.0.1:6789");
RedissonClient client = Redisson.create(config); RedissonClient client = Redisson.create(config);
RBucket<MyObject> bucket = client.getBucket('myObject');
// sync way // instance uses global retryInterval and timeout parameters
bucket.get(); RBucket<MyObject> bucket = client.getBucket('myObject');
// async way
RFuture<MyObject> result = bucket.getAsync();
// instance with overridden retryInterval and timeout parameters // instance with overridden retryInterval and timeout parameters
RBucket<MyObject> bucket = client.getBucket(PlainOptions.name('myObject') RBucket<MyObject> bucket = client.getBucket(PlainOptions.name('myObject')
.timeout(Duration.ofSeconds(3)) .timeout(Duration.ofSeconds(3))
.retryInterval(Duration.ofSeconds(5))); .retryInterval(Duration.ofSeconds(5)));
``` ```

@ -57,6 +57,11 @@ libraryDependencies += "org.redisson" % "redisson" % "xVERSIONx"
RMapRx<MyKey, MyValue> mapRx = redissonRx.getMap("myMap"); RMapRx<MyKey, MyValue> mapRx = redissonRx.getMap("myMap");
// client side caching
RLocalCachedMap<MyKey, MyValue> map = redisson.getLocalCachedMap(LocalCachedMapOptions.<MyKey, MyValue>name("myMap"));
// java.util.concurrent.locks.Lock // java.util.concurrent.locks.Lock
RLock lock = redisson.getLock("myLock"); RLock lock = redisson.getLock("myLock");
@ -65,10 +70,12 @@ libraryDependencies += "org.redisson" % "redisson" % "xVERSIONx"
RLockRx lockRx = redissonRx.getLock("myLock"); RLockRx lockRx = redissonRx.getLock("myLock");
// java.util.concurrent.ExecutorService // java.util.concurrent.ExecutorService
RExecutorService executor = redisson.getExecutorService("myExecutorService"); RExecutorService executor = redisson.getExecutorService("myExecutorService");
// over 50 Redis or Valkey based Java objects and services ... // over 50 Redis or Valkey based Java objects and services ...
``` ```

Loading…
Cancel
Save