
org.redisson.reactive.RedissonBucketReactive Maven / Gradle / Ivy
/**
* Copyright 2016 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.reactive;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonBucket;
import org.redisson.api.RBucketAsync;
import org.redisson.api.RBucketReactive;
import org.redisson.api.RFuture;
import org.redisson.client.codec.Codec;
import org.redisson.command.CommandReactiveExecutor;
/**
*
* @author Nikita Koksharov
*
* @param value type
*/
public class RedissonBucketReactive extends RedissonExpirableReactive implements RBucketReactive {
private final RBucketAsync instance;
public RedissonBucketReactive(CommandReactiveExecutor connectionManager, String name) {
super(connectionManager, name);
instance = new RedissonBucket(connectionManager, name);
}
public RedissonBucketReactive(Codec codec, CommandReactiveExecutor connectionManager, String name) {
super(codec, connectionManager, name);
instance = new RedissonBucket(codec, connectionManager, name);
}
@Override
public Publisher get() {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.getAsync();
}
});
}
@Override
public Publisher set(final V value) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.setAsync(value);
}
});
}
@Override
public Publisher set(final V value, final long timeToLive, final TimeUnit timeUnit) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.setAsync(value, timeToLive, timeUnit);
}
});
}
@Override
public Publisher size() {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.sizeAsync();
}
});
}
@Override
public Publisher trySet(final V value) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.trySetAsync(value);
}
});
}
@Override
public Publisher trySet(final V value, final long timeToLive, final TimeUnit timeUnit) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.trySetAsync(value, timeToLive, timeUnit);
}
});
}
@Override
public Publisher compareAndSet(final V expect, final V update) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.compareAndSetAsync(expect, update);
}
});
}
@Override
public Publisher getAndSet(final V newValue) {
return reactive(new Supplier>() {
@Override
public RFuture get() {
return instance.getAndSetAsync(newValue);
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy