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.RedisConnection
connection
(package private) io.vertx.mutiny.redis.client.Redis
redis
-
Constructor Summary
Constructors Constructor Description ReactiveRedisDataSourceImpl(io.vertx.mutiny.redis.client.Redis redis, io.vertx.mutiny.redis.client.RedisAPI api)
ReactiveRedisDataSourceImpl(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.Redis
getRedis()
<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 TransactionResult
toTransactionResult(io.vertx.mutiny.redis.client.Response response, TransactionHolder th)
io.smallrye.mutiny.Uni<Void>
withConnection(Function<ReactiveRedisDataSource,io.smallrye.mutiny.Uni<Void>> function)
Retrieves aReactiveRedisDataSource
using a single connection with the Redis Server.io.smallrye.mutiny.Uni<TransactionResult>
withTransaction(Function<ReactiveTransactionalRedisDataSource,io.smallrye.mutiny.Uni<Void>> function)
Retrieves aRedisDataSource
enqueuing commands in a Redis Transaction (MULTI
).io.smallrye.mutiny.Uni<TransactionResult>
withTransaction(Function<ReactiveTransactionalRedisDataSource,io.smallrye.mutiny.Uni<Void>> function, String... keys)
Retrieves aRedisDataSource
enqueuing 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
-
Methods inherited from interface io.quarkus.redis.runtime.datasource.RedisCommandExecutor
execute
-
-
-
-
Constructor Detail
-
ReactiveRedisDataSourceImpl
public ReactiveRedisDataSourceImpl(io.vertx.mutiny.redis.client.Redis redis, io.vertx.mutiny.redis.client.RedisAPI api)
-
ReactiveRedisDataSourceImpl
public ReactiveRedisDataSourceImpl(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:
execute
in interfaceRedisCommandExecutor
-
withTransaction
public io.smallrye.mutiny.Uni<TransactionResult> withTransaction(Function<ReactiveTransactionalRedisDataSource,io.smallrye.mutiny.Uni<Void>> function)
Description copied from interface:ReactiveRedisDataSource
Retrieves aRedisDataSource
enqueuing 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 thenull
item. The results of the commands are retrieved using the producedTransactionResult
. The user can discard a transaction using theTransactionalRedisDataSource.discard()
method. In this case, the producedTransactionResult
will be empty.- Specified by:
withTransaction
in 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:ReactiveRedisDataSource
Retrieves aRedisDataSource
enqueuing 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 thenull
item. The results of the commands are retrieved using the producedTransactionResult
. The user can discard a transaction using theTransactionalRedisDataSource.discard()
method. In this case, the producedTransactionResult
will be empty.- Specified by:
withTransaction
in 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.
-
toTransactionResult
public static TransactionResult toTransactionResult(io.vertx.mutiny.redis.client.Response response, TransactionHolder th)
-
execute
public io.smallrye.mutiny.Uni<io.vertx.mutiny.redis.client.Response> execute(String command, String... args)
Description copied from interface:ReactiveRedisDataSource
Executes a command. This method is used to execute commands not offered by the API.- Specified by:
execute
in 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:ReactiveRedisDataSource
Executes a command. This method is used to execute commands not offered by the API.- Specified by:
execute
in 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:ReactiveRedisDataSource
Executes a command. This method is used to execute commands not offered by the API.- Specified by:
execute
in 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:ReactiveRedisDataSource
Retrieves aReactiveRedisDataSource
using a single connection with the Redis Server. The connection is acquired from the pool and released when theUni
returned byfunction
produces anull
item or a failure.- Specified by:
withConnection
in interfaceReactiveRedisDataSource
- Parameters:
function
- the function receiving the single-connection data source and producingnull
when the connection can be released.
-
select
public io.smallrye.mutiny.Uni<Void> select(long index)
Description copied from interface:ReactiveRedisDataSource
Execute 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:
select
in interfaceReactiveRedisDataSource
- Parameters:
index
- the database index.
-
flushall
public io.smallrye.mutiny.Uni<Void> flushall()
Description copied from interface:ReactiveRedisDataSource
Execute the command FLUSHALL. Summary: Remove all keys from all databases Group: server Requires Redis 1.0.0- Specified by:
flushall
in interfaceReactiveRedisDataSource
-
hash
public <K,F,V> ReactiveHashCommands<K,F,V> hash(Class<K> redisKeyType, Class<F> fieldType, Class<V> valueType)
Description copied from interface:ReactiveRedisDataSource
Gets 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:
hash
in 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:ReactiveRedisDataSource
Gets the object to execute commands manipulating geo items (a.k.a.{longitude, latitude, member}
).V
represents the type of the member, i.e. the localized thing.- Specified by:
geo
in 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:ReactiveRedisDataSource
Gets the object to execute commands manipulating keys and expiration times.- Specified by:
key
in 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:ReactiveRedisDataSource
Gets the object to execute commands manipulating sorted sets.- Specified by:
sortedSet
in 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:ReactiveRedisDataSource
Gets the object to execute commands manipulating stored strings.- Specified by:
string
in 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:ReactiveRedisDataSource
Gets the object to execute commands manipulating sets.- Specified by:
set
in 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:ReactiveRedisDataSource
Gets the object to execute commands manipulating lists.- Specified by:
list
in 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:ReactiveRedisDataSource
Gets the object to execute commands manipulating hyperloglog data structures.- Specified by:
hyperloglog
in 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:ReactiveRedisDataSource
Gets the object to execute commands manipulating bitmap data structures.- Specified by:
bitmap
in 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:ReactiveRedisDataSource
Gets the objects to publish and receive messages.- Specified by:
pubsub
in 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:
getRedis
in interfaceReactiveRedisDataSource
- Returns:
- the underlying Redis client.
-
-