Class BlockingRedisDataSourceImpl
- java.lang.Object
-
- io.quarkus.redis.runtime.datasource.BlockingRedisDataSourceImpl
-
- All Implemented Interfaces:
RedisDataSource
public class BlockingRedisDataSourceImpl extends Object implements RedisDataSource
-
-
Field Summary
Fields Modifier and Type Field Description (package private) io.vertx.mutiny.redis.client.RedisConnection
connection
(package private) ReactiveRedisDataSourceImpl
reactive
-
Constructor Summary
Constructors Constructor Description BlockingRedisDataSourceImpl(ReactiveRedisDataSourceImpl reactive, Duration timeout)
BlockingRedisDataSourceImpl(io.vertx.mutiny.core.Vertx vertx, io.vertx.mutiny.redis.client.Redis redis, io.vertx.mutiny.redis.client.RedisAPI api, Duration timeout)
BlockingRedisDataSourceImpl(io.vertx.mutiny.core.Vertx vertx, io.vertx.mutiny.redis.client.Redis redis, io.vertx.mutiny.redis.client.RedisConnection connection, Duration timeout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <K> BitMapCommands<K>
bitmap(Class<K> redisKeyType)
Gets the object to execute commands manipulating bitmap data structures.io.vertx.mutiny.redis.client.Response
execute(io.vertx.mutiny.redis.client.Command command, String... args)
Executes a command.io.vertx.mutiny.redis.client.Response
execute(io.vertx.redis.client.Command command, String... args)
Executes a command.io.vertx.mutiny.redis.client.Response
execute(String command, String... args)
Executes a command.void
flushall()
Execute the command FLUSHALL.<K1,V1>
GeoCommands<K1,V1>geo(Class<K1> redisKeyType, Class<V1> memberType)
Gets the object to execute commands manipulating geo items (a.k.a.ReactiveRedisDataSource
getReactive()
<K1,F,V1>
HashCommands<K1,F,V1>hash(Class<K1> redisKeyType, Class<F> typeOfField, Class<V1> typeOfValue)
Gets the object to execute commands manipulating hashes (a.k.a.<K1,V1>
HyperLogLogCommands<K1,V1>hyperloglog(Class<K1> redisKeyType, Class<V1> memberType)
Gets the object to execute commands manipulating hyperloglog data structures.<K1> KeyCommands<K1>
key(Class<K1> redisKeyType)
Gets the object to execute commands manipulating keys and expiration times.<K1,V1>
ListCommands<K1,V1>list(Class<K1> redisKeyType, Class<V1> memberType)
Gets the object to execute commands manipulating lists.<V> PubSubCommands<V>
pubsub(Class<V> messageType)
Gets the objects to publish and receive messages.void
select(long index)
Execute the command SELECT.<K1,V1>
SetCommands<K1,V1>set(Class<K1> redisKeyType, Class<V1> memberType)
Gets the object to execute commands manipulating sets.<K1,V1>
SortedSetCommands<K1,V1>sortedSet(Class<K1> redisKeyType, Class<V1> valueType)
Gets the object to execute commands manipulating sorted sets.<K1,V1>
StringCommands<K1,V1>string(Class<K1> redisKeyType, Class<V1> valueType)
Gets the object to execute commands manipulating stored strings.void
withConnection(Consumer<RedisDataSource> consumer)
Retrieves aRedisDataSource
using a single connection with the Redis server.TransactionResult
withTransaction(Consumer<TransactionalRedisDataSource> ds)
Retrieves aRedisDataSource
enqueuing commands in a Redis Transaction (MULTI
).TransactionResult
withTransaction(Consumer<TransactionalRedisDataSource> ds, String... watchedKeys)
Retrieves aRedisDataSource
enqueuing commands in a Redis Transaction (MULTI
).<I> OptimisticLockingTransactionResult<I>
withTransaction(Function<RedisDataSource,I> preTxBlock, BiConsumer<I,TransactionalRedisDataSource> tx, String... watchedKeys)
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.RedisDataSource
bitmap, geo, hash, hyperloglog, key, list, set, sortedSet, string
-
-
-
-
Field Detail
-
reactive
final ReactiveRedisDataSourceImpl reactive
-
connection
final io.vertx.mutiny.redis.client.RedisConnection connection
-
-
Constructor Detail
-
BlockingRedisDataSourceImpl
public BlockingRedisDataSourceImpl(io.vertx.mutiny.core.Vertx vertx, io.vertx.mutiny.redis.client.Redis redis, io.vertx.mutiny.redis.client.RedisAPI api, Duration timeout)
-
BlockingRedisDataSourceImpl
public BlockingRedisDataSourceImpl(ReactiveRedisDataSourceImpl reactive, Duration timeout)
-
BlockingRedisDataSourceImpl
public BlockingRedisDataSourceImpl(io.vertx.mutiny.core.Vertx vertx, io.vertx.mutiny.redis.client.Redis redis, io.vertx.mutiny.redis.client.RedisConnection connection, Duration timeout)
-
-
Method Detail
-
withTransaction
public TransactionResult withTransaction(Consumer<TransactionalRedisDataSource> ds)
Description copied from interface:RedisDataSource
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 completes.The results of the commands are retrieved using the returned
TransactionResult
.The user can discard a transaction using the
TransactionalRedisDataSource.discard()
method. In this case, the producedTransactionResult
will be empty.- Specified by:
withTransaction
in interfaceRedisDataSource
- Parameters:
ds
- the consumer receiving the transactional redis data source. The enqueued commands are only executed at the end of the block.
-
withTransaction
public TransactionResult withTransaction(Consumer<TransactionalRedisDataSource> ds, String... watchedKeys)
Description copied from interface:RedisDataSource
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 completes.The results of the commands are retrieved using the returned
TransactionResult
.The user can discard a transaction using the
TransactionalRedisDataSource.discard()
method. In this case, the producedTransactionResult
will be empty.- Specified by:
withTransaction
in interfaceRedisDataSource
- Parameters:
ds
- 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.
-
withTransaction
public <I> OptimisticLockingTransactionResult<I> withTransaction(Function<RedisDataSource,I> preTxBlock, BiConsumer<I,TransactionalRedisDataSource> tx, String... watchedKeys)
Description copied from interface:RedisDataSource
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.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 EXEC
The
preTxBlock
returns aRedisDataSource
. The produced value is received by thetx
block, 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 thepreTxBlock
must used the passed (single-connection)RedisDataSource
instance.If the
preTxBlock
throws an exception, the transaction is not executed, and the returnedOptimisticLockingTransactionResult
is 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 producedOptimisticLockingTransactionResult
will be empty.- Specified by:
withTransaction
in interfaceRedisDataSource
tx
- 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.
-
withConnection
public void withConnection(Consumer<RedisDataSource> consumer)
Description copied from interface:RedisDataSource
Retrieves aRedisDataSource
using a single connection with the Redis server. The connection is acquired from the pool, and released then the consumer completes.- Specified by:
withConnection
in interfaceRedisDataSource
- Parameters:
consumer
- the consumer receiving the connection and returning when the connection can be released.
-
select
public void select(long index)
Description copied from interface:RedisDataSource
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
RedisDataSource.withConnection(Consumer)
block.- Specified by:
select
in interfaceRedisDataSource
- Parameters:
index
- the database index.
-
flushall
public void flushall()
Description copied from interface:RedisDataSource
Execute the command FLUSHALL. Summary: Remove all keys from all databases Group: server Requires Redis 1.0.0- Specified by:
flushall
in interfaceRedisDataSource
-
hash
public <K1,F,V1> HashCommands<K1,F,V1> hash(Class<K1> redisKeyType, Class<F> typeOfField, Class<V1> typeOfValue)
Description copied from interface:RedisDataSource
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 interfaceRedisDataSource
- Type Parameters:
K1
- the type of the redis keyF
- the type of the fields (map's keys)V1
- the type of the value- Parameters:
redisKeyType
- the class of the keystypeOfField
- the class of the fieldstypeOfValue
- the class of the values- Returns:
- the object to execute commands manipulating hashes (a.k.a.
Map<K, V>
).
-
geo
public <K1,V1> GeoCommands<K1,V1> geo(Class<K1> redisKeyType, Class<V1> memberType)
Description copied from interface:RedisDataSource
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 interfaceRedisDataSource
- Type Parameters:
K1
- the type of the redis keyV1
- 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 <K1> KeyCommands<K1> key(Class<K1> redisKeyType)
Description copied from interface:RedisDataSource
Gets the object to execute commands manipulating keys and expiration times.- Specified by:
key
in interfaceRedisDataSource
- Type Parameters:
K1
- the type of the key- Parameters:
redisKeyType
- the type of the keys- Returns:
- the object to execute commands manipulating keys.
-
sortedSet
public <K1,V1> SortedSetCommands<K1,V1> sortedSet(Class<K1> redisKeyType, Class<V1> valueType)
Description copied from interface:RedisDataSource
Gets the object to execute commands manipulating sorted sets.- Specified by:
sortedSet
in interfaceRedisDataSource
- Type Parameters:
K1
- the type of the keyV1
- 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 <K1,V1> StringCommands<K1,V1> string(Class<K1> redisKeyType, Class<V1> valueType)
Description copied from interface:RedisDataSource
Gets the object to execute commands manipulating stored strings.- Specified by:
string
in interfaceRedisDataSource
- Type Parameters:
K1
- the type of the keyV1
- 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 <K1,V1> SetCommands<K1,V1> set(Class<K1> redisKeyType, Class<V1> memberType)
Description copied from interface:RedisDataSource
Gets the object to execute commands manipulating sets.- Specified by:
set
in interfaceRedisDataSource
- Type Parameters:
K1
- the type of the keyV1
- 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 <K1,V1> ListCommands<K1,V1> list(Class<K1> redisKeyType, Class<V1> memberType)
Description copied from interface:RedisDataSource
Gets the object to execute commands manipulating lists.- Specified by:
list
in interfaceRedisDataSource
- Type Parameters:
K1
- the type of the keyV1
- 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 <K1,V1> HyperLogLogCommands<K1,V1> hyperloglog(Class<K1> redisKeyType, Class<V1> memberType)
Description copied from interface:RedisDataSource
Gets the object to execute commands manipulating hyperloglog data structures.- Specified by:
hyperloglog
in interfaceRedisDataSource
- Type Parameters:
K1
- the type of the keyV1
- 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> BitMapCommands<K> bitmap(Class<K> redisKeyType)
Description copied from interface:RedisDataSource
Gets the object to execute commands manipulating bitmap data structures.- Specified by:
bitmap
in interfaceRedisDataSource
- 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> PubSubCommands<V> pubsub(Class<V> messageType)
Description copied from interface:RedisDataSource
Gets the objects to publish and receive messages.- Specified by:
pubsub
in interfaceRedisDataSource
- Type Parameters:
V
- the type of message- Parameters:
messageType
- the type of message- Returns:
- the object to publish and subscribe to Redis channels
-
execute
public io.vertx.mutiny.redis.client.Response execute(String command, String... args)
Description copied from interface:RedisDataSource
Executes a command. This method is used to execute commands not offered by the API.- Specified by:
execute
in interfaceRedisDataSource
- Parameters:
command
- the command nameargs
- the parameters, encoded as String.- Returns:
- the response
-
execute
public io.vertx.mutiny.redis.client.Response execute(io.vertx.mutiny.redis.client.Command command, String... args)
Description copied from interface:RedisDataSource
Executes a command. This method is used to execute commands not offered by the API.- Specified by:
execute
in interfaceRedisDataSource
- Parameters:
command
- the commandargs
- the parameters, encoded as String.- Returns:
- the response
-
execute
public io.vertx.mutiny.redis.client.Response execute(io.vertx.redis.client.Command command, String... args)
Description copied from interface:RedisDataSource
Executes a command. This method is used to execute commands not offered by the API.- Specified by:
execute
in interfaceRedisDataSource
- Parameters:
command
- the commandargs
- the parameters, encoded as String.- Returns:
- the response
-
getReactive
public ReactiveRedisDataSource getReactive()
- Specified by:
getReactive
in interfaceRedisDataSource
- Returns:
- the reactive data source.
-
-