Class ReactiveRedisDataSourceImpl
- java.lang.Object
-
- io.quarkus.redis.runtime.datasource.ReactiveRedisDataSourceImpl
-
- All Implemented Interfaces:
ReactiveRedisDataSource,RedisCommandExecutor
public class ReactiveRedisDataSourceImpl extends Object implements ReactiveRedisDataSource, RedisCommandExecutor
-
-
Field Summary
Fields Modifier and Type Field Description (package private) io.vertx.mutiny.redis.client.RedisConnectionconnection(package private) io.vertx.mutiny.redis.client.Redisredis
-
Constructor Summary
Constructors Constructor Description ReactiveRedisDataSourceImpl(io.vertx.mutiny.core.Vertx vertx, io.vertx.mutiny.redis.client.Redis redis, io.vertx.mutiny.redis.client.RedisAPI api)ReactiveRedisDataSourceImpl(io.vertx.mutiny.core.Vertx vertx, io.vertx.mutiny.redis.client.Redis redis, io.vertx.mutiny.redis.client.RedisConnection connection)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <K> ReactiveBitMapCommands<K>bitmap(Class<K> redisKeyType)Gets the object to execute commands manipulating bitmap data structures.io.smallrye.mutiny.Uni<io.vertx.mutiny.redis.client.Response>execute(io.vertx.mutiny.redis.client.Command command, String... args)Executes a command.io.smallrye.mutiny.Uni<io.vertx.mutiny.redis.client.Response>execute(io.vertx.mutiny.redis.client.Request request)io.smallrye.mutiny.Uni<io.vertx.mutiny.redis.client.Response>execute(io.vertx.redis.client.Command command, String... args)Executes a command.io.smallrye.mutiny.Uni<io.vertx.mutiny.redis.client.Response>execute(String command, String... args)Executes a command.io.smallrye.mutiny.Uni<Void>flushall()Execute the command FLUSHALL.<K,V>
ReactiveGeoCommands<K,V>geo(Class<K> redisKeyType, Class<V> memberType)Gets the object to execute commands manipulating geo items (a.k.a.io.vertx.mutiny.redis.client.RedisgetRedis()io.vertx.mutiny.core.VertxgetVertx()<K,F,V>
ReactiveHashCommands<K,F,V>hash(Class<K> redisKeyType, Class<F> fieldType, Class<V> valueType)Gets the object to execute commands manipulating hashes (a.k.a.<K,V>
ReactiveHyperLogLogCommands<K,V>hyperloglog(Class<K> redisKeyType, Class<V> memberType)Gets the object to execute commands manipulating hyperloglog data structures.<K> ReactiveKeyCommands<K>key(Class<K> redisKeyType)Gets the object to execute commands manipulating keys and expiration times.<K,V>
ReactiveListCommands<K,V>list(Class<K> redisKeyType, Class<V> memberType)Gets the object to execute commands manipulating lists.<V> ReactivePubSubCommands<V>pubsub(Class<V> messageType)Gets the objects to publish and receive messages.io.smallrye.mutiny.Uni<Void>select(long index)Execute the command SELECT.<K,V>
ReactiveSetCommands<K,V>set(Class<K> redisKeyType, Class<V> memberType)Gets the object to execute commands manipulating sets.<K,V>
ReactiveSortedSetCommands<K,V>sortedSet(Class<K> redisKeyType, Class<V> valueType)Gets the object to execute commands manipulating sorted sets.<K,V>
ReactiveStringCommands<K,V>string(Class<K> redisKeyType, Class<V> valueType)Gets the object to execute commands manipulating stored strings.static TransactionResulttoTransactionResult(io.vertx.mutiny.redis.client.Response response, TransactionHolder th)static <I> OptimisticLockingTransactionResult<I>toTransactionResult(io.vertx.mutiny.redis.client.Response response, I input, TransactionHolder th)<K,V>
ReactiveValueCommands<K,V>value(Class<K> redisKeyType, Class<V> valueType)Gets the object to execute commands manipulating stored strings.io.smallrye.mutiny.Uni<Void>withConnection(Function<ReactiveRedisDataSource,io.smallrye.mutiny.Uni<Void>> function)Retrieves aReactiveRedisDataSourceusing a single connection with the Redis Server.<I> io.smallrye.mutiny.Uni<OptimisticLockingTransactionResult<I>>withTransaction(Function<ReactiveRedisDataSource,io.smallrye.mutiny.Uni<I>> preTxBlock, BiFunction<I,ReactiveTransactionalRedisDataSource,io.smallrye.mutiny.Uni<Void>> tx, String... watchedKeys)Retrieves aRedisDataSourceenqueuing commands in a Redis Transaction (MULTI).io.smallrye.mutiny.Uni<TransactionResult>withTransaction(Function<ReactiveTransactionalRedisDataSource,io.smallrye.mutiny.Uni<Void>> function)Retrieves aRedisDataSourceenqueuing commands in a Redis Transaction (MULTI).io.smallrye.mutiny.Uni<TransactionResult>withTransaction(Function<ReactiveTransactionalRedisDataSource,io.smallrye.mutiny.Uni<Void>> function, String... keys)Retrieves aRedisDataSourceenqueuing commands in a Redis Transaction (MULTI).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.quarkus.redis.datasource.ReactiveRedisDataSource
bitmap, geo, hash, hyperloglog, key, list, set, sortedSet, string, value
-
Methods inherited from interface io.quarkus.redis.runtime.datasource.RedisCommandExecutor
execute
-
-
-
-
Constructor Detail
-
ReactiveRedisDataSourceImpl
public ReactiveRedisDataSourceImpl(io.vertx.mutiny.core.Vertx vertx, io.vertx.mutiny.redis.client.Redis redis, io.vertx.mutiny.redis.client.RedisAPI api)
-
ReactiveRedisDataSourceImpl
public ReactiveRedisDataSourceImpl(io.vertx.mutiny.core.Vertx vertx, io.vertx.mutiny.redis.client.Redis redis, io.vertx.mutiny.redis.client.RedisConnection connection)
-
-
Method Detail
-
execute
public io.smallrye.mutiny.Uni<io.vertx.mutiny.redis.client.Response> execute(io.vertx.mutiny.redis.client.Request request)
- Specified by:
executein interfaceRedisCommandExecutor
-
withTransaction
public io.smallrye.mutiny.Uni<TransactionResult> withTransaction(Function<ReactiveTransactionalRedisDataSource,io.smallrye.mutiny.Uni<Void>> function)
Description copied from interface:ReactiveRedisDataSourceRetrieves aRedisDataSourceenqueuing commands in a Redis Transaction (MULTI). Note that transaction acquires a single connection, and all the commands are enqueued in this connection. The commands are only executed when the passed block emits thenullitem.The results of the commands are retrieved using the produced
TransactionResult.The user can discard a transaction using the
TransactionalRedisDataSource.discard()method. In this case, the producedTransactionResultwill be empty.- Specified by:
withTransactionin interfaceReactiveRedisDataSource- Parameters:
function- the consumer receiving the transactional redis data source. The enqueued commands are only executed at the end of the block.
-
withTransaction
public io.smallrye.mutiny.Uni<TransactionResult> withTransaction(Function<ReactiveTransactionalRedisDataSource,io.smallrye.mutiny.Uni<Void>> function, String... keys)
Description copied from interface:ReactiveRedisDataSourceRetrieves aRedisDataSourceenqueuing commands in a Redis Transaction (MULTI). Note that transaction acquires a single connection, and all the commands are enqueued in this connection. The commands are only executed when the passed block emits thenullitem.The results of the commands are retrieved using the produced
TransactionResult.The user can discard a transaction using the
TransactionalRedisDataSource.discard()method. In this case, the producedTransactionResultwill be empty.- Specified by:
withTransactionin interfaceReactiveRedisDataSource- Parameters:
function- the consumer receiving the transactional redis data source. The enqueued commands are only executed at the end of the block.keys- the keys to watch during the execution of the transaction. If one of these key is modified before the completion of the transaction, the transaction is discarded.
-
withTransaction
public <I> io.smallrye.mutiny.Uni<OptimisticLockingTransactionResult<I>> withTransaction(Function<ReactiveRedisDataSource,io.smallrye.mutiny.Uni<I>> preTxBlock, BiFunction<I,ReactiveTransactionalRedisDataSource,io.smallrye.mutiny.Uni<Void>> tx, String... watchedKeys)
Description copied from interface:ReactiveRedisDataSourceRetrieves aRedisDataSourceenqueuing commands in a Redis Transaction (MULTI). Note that transaction acquires a single connection, and all the commands are enqueued in this connection. The commands are only executed when the passed block emits thenullitem.This variant also allows executing code before the transaction gets started but after the key being watched:
WATCH key // preTxBlock element = ZRANGE k 0 0 // TxBlock MULTI ZREM k element EXECThe
preTxBlockreturns aUni<I>. The produced value is received by thetxblock, which can use that value to execute the appropriate operation in the transaction. The produced value can also be retrieved from the producedOptimisticLockingTransactionResult. Commands issued in thepreTxBlockmust used the passed (single-connection)ReactiveRedisDataSourceinstance.If the
preTxBlockthrows an exception or emits a failure, the transaction is not executed, and the returnedOptimisticLockingTransactionResultis empty.This construct allows implementing operation relying on optimistic locking. The results of the commands are retrieved using the produced
OptimisticLockingTransactionResult.The user can discard a transaction using the
TransactionalRedisDataSource.discard()method. In this case, the producedOptimisticLockingTransactionResultwill be empty.- Specified by:
withTransactionin interfaceReactiveRedisDataSourcetx- the consumer receiving the transactional redis data source. The enqueued commands are only executed at the end of the block.watchedKeys- the keys to watch during the execution of the transaction. If one of these key is modified before the completion of the transaction, the transaction is discarded.
-
toTransactionResult
public static TransactionResult toTransactionResult(io.vertx.mutiny.redis.client.Response response, TransactionHolder th)
-
toTransactionResult
public static <I> OptimisticLockingTransactionResult<I> toTransactionResult(io.vertx.mutiny.redis.client.Response response, I input, TransactionHolder th)
-
execute
public io.smallrye.mutiny.Uni<io.vertx.mutiny.redis.client.Response> execute(String command, String... args)
Description copied from interface:ReactiveRedisDataSourceExecutes a command. This method is used to execute commands not offered by the API.- Specified by:
executein interfaceReactiveRedisDataSource- Parameters:
command- the command nameargs- the parameters, encoded as String.- Returns:
- the response
-
execute
public io.smallrye.mutiny.Uni<io.vertx.mutiny.redis.client.Response> execute(io.vertx.mutiny.redis.client.Command command, String... args)Description copied from interface:ReactiveRedisDataSourceExecutes a command. This method is used to execute commands not offered by the API.- Specified by:
executein interfaceReactiveRedisDataSource- Parameters:
command- the commandargs- the parameters, encoded as String.- Returns:
- the response
-
execute
public io.smallrye.mutiny.Uni<io.vertx.mutiny.redis.client.Response> execute(io.vertx.redis.client.Command command, String... args)Description copied from interface:ReactiveRedisDataSourceExecutes a command. This method is used to execute commands not offered by the API.- Specified by:
executein interfaceReactiveRedisDataSource- Parameters:
command- the commandargs- the parameters, encoded as String.- Returns:
- the response
-
withConnection
public io.smallrye.mutiny.Uni<Void> withConnection(Function<ReactiveRedisDataSource,io.smallrye.mutiny.Uni<Void>> function)
Description copied from interface:ReactiveRedisDataSourceRetrieves aReactiveRedisDataSourceusing a single connection with the Redis Server. The connection is acquired from the pool and released when theUnireturned byfunctionproduces anullitem or a failure.- Specified by:
withConnectionin interfaceReactiveRedisDataSource- Parameters:
function- the function receiving the single-connection data source and producingnullwhen the connection can be released.
-
select
public io.smallrye.mutiny.Uni<Void> select(long index)
Description copied from interface:ReactiveRedisDataSourceExecute the command SELECT. Summary: Change the selected database for the current connection Group: connection Requires Redis 1.0.0This method is expected to be used inside a
ReactiveRedisDataSource.withConnection(Function)block.- Specified by:
selectin interfaceReactiveRedisDataSource- Parameters:
index- the database index.
-
flushall
public io.smallrye.mutiny.Uni<Void> flushall()
Description copied from interface:ReactiveRedisDataSourceExecute the command FLUSHALL. Summary: Remove all keys from all databases Group: server Requires Redis 1.0.0- Specified by:
flushallin interfaceReactiveRedisDataSource
-
hash
public <K,F,V> ReactiveHashCommands<K,F,V> hash(Class<K> redisKeyType, Class<F> fieldType, Class<V> valueType)
Description copied from interface:ReactiveRedisDataSourceGets the object to execute commands manipulating hashes (a.k.a.Map<F, V>).If you want to use a hash of
<String -> Person>stored using String identifier, you would use:hash(String.class, String.class, Person.class). If you want to use a hash of<String -> Person>stored using UUID identifier, you would use:hash(UUID.class, String.class, Person.class).- Specified by:
hashin interfaceReactiveRedisDataSource- Type Parameters:
K- the type of the redis keyF- the type of the fields (map's keys)V- the type of the value- Parameters:
redisKeyType- the class of the keysfieldType- the class of the fieldsvalueType- the class of the values- Returns:
- the object to execute commands manipulating hashes (a.k.a.
Map<K, V>).
-
geo
public <K,V> ReactiveGeoCommands<K,V> geo(Class<K> redisKeyType, Class<V> memberType)
Description copied from interface:ReactiveRedisDataSourceGets the object to execute commands manipulating geo items (a.k.a.{longitude, latitude, member}).Vrepresents the type of the member, i.e. the localized thing.- Specified by:
geoin interfaceReactiveRedisDataSource- Type Parameters:
K- the type of the redis keyV- the type of the member- Parameters:
redisKeyType- the class of the keysmemberType- the class of the members- Returns:
- the object to execute geo commands.
-
key
public <K> ReactiveKeyCommands<K> key(Class<K> redisKeyType)
Description copied from interface:ReactiveRedisDataSourceGets the object to execute commands manipulating keys and expiration times.- Specified by:
keyin interfaceReactiveRedisDataSource- Type Parameters:
K- the type of the key- Parameters:
redisKeyType- the type of the keys- Returns:
- the object to execute commands manipulating keys.
-
sortedSet
public <K,V> ReactiveSortedSetCommands<K,V> sortedSet(Class<K> redisKeyType, Class<V> valueType)
Description copied from interface:ReactiveRedisDataSourceGets the object to execute commands manipulating sorted sets.- Specified by:
sortedSetin interfaceReactiveRedisDataSource- Type Parameters:
K- the type of the keyV- the type of the value- Parameters:
redisKeyType- the type of the keysvalueType- the type of the value sorted in the sorted sets- Returns:
- the object to manipulate sorted sets.
-
string
public <K,V> ReactiveStringCommands<K,V> string(Class<K> redisKeyType, Class<V> valueType)
Description copied from interface:ReactiveRedisDataSourceGets the object to execute commands manipulating stored strings.- Specified by:
stringin interfaceReactiveRedisDataSource- Type Parameters:
K- the type of the keyV- the type of the value- Parameters:
redisKeyType- the type of the keysvalueType- the type of the value, often String, or the value are encoded/decoded using codecs.- Returns:
- the object to manipulate stored strings.
-
value
public <K,V> ReactiveValueCommands<K,V> value(Class<K> redisKeyType, Class<V> valueType)
Description copied from interface:ReactiveRedisDataSourceGets the object to execute commands manipulating stored strings.NOTE: Instead of
string, this group is namedvalueto avoid the confusion with the Java String type. Indeed, Redis strings can be strings, numbers, byte arrays...- Specified by:
valuein interfaceReactiveRedisDataSource- Type Parameters:
K- the type of the keyV- the type of the value- Parameters:
redisKeyType- the type of the keysvalueType- the type of the value, often String, or the value are encoded/decoded using codecs.- Returns:
- the object to manipulate stored strings.
-
set
public <K,V> ReactiveSetCommands<K,V> set(Class<K> redisKeyType, Class<V> memberType)
Description copied from interface:ReactiveRedisDataSourceGets the object to execute commands manipulating sets.- Specified by:
setin interfaceReactiveRedisDataSource- Type Parameters:
K- the type of the keyV- the type of the member- Parameters:
redisKeyType- the type of the keysmemberType- the type of the member stored in each set- Returns:
- the object to manipulate sets.
-
list
public <K,V> ReactiveListCommands<K,V> list(Class<K> redisKeyType, Class<V> memberType)
Description copied from interface:ReactiveRedisDataSourceGets the object to execute commands manipulating lists.- Specified by:
listin interfaceReactiveRedisDataSource- Type Parameters:
K- the type of the keyV- the type of the member- Parameters:
redisKeyType- the type of the keysmemberType- the type of the member stored in each list- Returns:
- the object to manipulate sets.
-
hyperloglog
public <K,V> ReactiveHyperLogLogCommands<K,V> hyperloglog(Class<K> redisKeyType, Class<V> memberType)
Description copied from interface:ReactiveRedisDataSourceGets the object to execute commands manipulating hyperloglog data structures.- Specified by:
hyperloglogin interfaceReactiveRedisDataSource- Type Parameters:
K- the type of the keyV- the type of the member- Parameters:
redisKeyType- the type of the keysmemberType- the type of the member stored in the data structure- Returns:
- the object to manipulate hyper log log data structures.
-
bitmap
public <K> ReactiveBitMapCommands<K> bitmap(Class<K> redisKeyType)
Description copied from interface:ReactiveRedisDataSourceGets the object to execute commands manipulating bitmap data structures.- Specified by:
bitmapin interfaceReactiveRedisDataSource- Type Parameters:
K- the type of the key- Parameters:
redisKeyType- the type of the keys- Returns:
- the object to manipulate bitmap data structures.
-
pubsub
public <V> ReactivePubSubCommands<V> pubsub(Class<V> messageType)
Description copied from interface:ReactiveRedisDataSourceGets the objects to publish and receive messages.- Specified by:
pubsubin interfaceReactiveRedisDataSource- Type Parameters:
V- the type of message- Parameters:
messageType- the type of message- Returns:
- the object to publish and subscribe to Redis channels
-
getRedis
public io.vertx.mutiny.redis.client.Redis getRedis()
- Specified by:
getRedisin interfaceReactiveRedisDataSource- Returns:
- the underlying Redis client.
-
getVertx
public io.vertx.mutiny.core.Vertx getVertx()
-
-