Class ReactiveRedisDataSourceImpl

    • Field Detail

      • redis

        final io.vertx.mutiny.redis.client.Redis redis
      • connection

        final io.vertx.mutiny.redis.client.RedisConnection connection
    • 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:
        execute in interface RedisCommandExecutor
      • withTransaction

        public io.smallrye.mutiny.Uni<TransactionResult> withTransaction​(Function<ReactiveTransactionalRedisDataSource,​io.smallrye.mutiny.Uni<Void>> function,
                                                                         String... keys)
        Description copied from interface: ReactiveRedisDataSource
        Retrieves a RedisDataSource 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 the null item.

        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 produced TransactionResult will be empty.

        Specified by:
        withTransaction in interface ReactiveRedisDataSource
        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: ReactiveRedisDataSource
        Retrieves a RedisDataSource 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 the null 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 a Uni<I>. The produced value is received by the tx block, which can use that value to execute the appropriate operation in the transaction. The produced value can also be retrieved from the produced OptimisticLockingTransactionResult. Commands issued in the preTxBlock must used the passed (single-connection) ReactiveRedisDataSource instance.

        If the preTxBlock throws an exception or emits a failure, the transaction is not executed, and the returned OptimisticLockingTransactionResult 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 produced OptimisticLockingTransactionResult will be empty.

        Specified by:
        withTransaction in interface ReactiveRedisDataSource
        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.
      • 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 interface ReactiveRedisDataSource
        Parameters:
        command - the command name
        args - 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 interface ReactiveRedisDataSource
        Parameters:
        command - the command
        args - 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 interface ReactiveRedisDataSource
        Parameters:
        command - the command
        args - 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 a ReactiveRedisDataSource using a single connection with the Redis Server. The connection is acquired from the pool and released when the Uni returned by function produces a null item or a failure.
        Specified by:
        withConnection in interface ReactiveRedisDataSource
        Parameters:
        function - the function receiving the single-connection data source and producing null when the connection can be released.
      • 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&lt;F, V&gt;).

        If you want to use a hash of &lt;String -> Person&gt; stored using String identifier, you would use: hash(String.class, String.class, Person.class). If you want to use a hash of &lt;String -> Person&gt; stored using UUID identifier, you would use: hash(UUID.class, String.class, Person.class).

        Specified by:
        hash in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the redis key
        F - the type of the fields (map's keys)
        V - the type of the value
        Parameters:
        redisKeyType - the class of the keys
        fieldType - the class of the fields
        valueType - the class of the values
        Returns:
        the object to execute commands manipulating hashes (a.k.a. Map&lt;K, V&gt;).
      • hash

        public <K,​F,​V> ReactiveHashCommands<K,​F,​V> hash​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                                                com.fasterxml.jackson.core.type.TypeReference<F> fieldType,
                                                                                com.fasterxml.jackson.core.type.TypeReference<V> valueType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to execute commands manipulating hashes (a.k.a. Map&lt;F, V&gt;).

        If you want to use a hash of &lt;String -> Person&gt; stored using String identifier, you would use: hash(String.class, String.class, Person.class). If you want to use a hash of &lt;String -> Person&gt; stored using UUID identifier, you would use: hash(UUID.class, String.class, Person.class).

        Specified by:
        hash in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the redis key
        F - the type of the fields (map's keys)
        V - the type of the value
        Parameters:
        redisKeyType - the class of the keys
        fieldType - the class of the fields
        valueType - the class of the values
        Returns:
        the object to execute commands manipulating hashes (a.k.a. Map&lt;K, V&gt;).
      • 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 interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the redis key
        V - the type of the member
        Parameters:
        redisKeyType - the class of the keys
        memberType - the class of the members
        Returns:
        the object to execute geo commands.
      • geo

        public <K,​V> ReactiveGeoCommands<K,​V> geo​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                              com.fasterxml.jackson.core.type.TypeReference<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 interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the redis key
        V - the type of the member
        Parameters:
        redisKeyType - the class of the keys
        memberType - 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 interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        Parameters:
        redisKeyType - the type of the keys
        Returns:
        the object to execute commands manipulating keys.
      • key

        public <K> ReactiveKeyCommands<K> key​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to execute commands manipulating keys and expiration times.
        Specified by:
        key in interface ReactiveRedisDataSource
        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 interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the value
        Parameters:
        redisKeyType - the type of the keys
        valueType - the type of the value sorted in the sorted sets
        Returns:
        the object to manipulate sorted sets.
      • sortedSet

        public <K,​V> ReactiveSortedSetCommands<K,​V> sortedSet​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                                          com.fasterxml.jackson.core.type.TypeReference<V> valueType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to execute commands manipulating sorted sets.
        Specified by:
        sortedSet in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the value
        Parameters:
        redisKeyType - the type of the keys
        valueType - 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 interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the value
        Parameters:
        redisKeyType - the type of the keys
        valueType - 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: ReactiveRedisDataSource
        Gets the object to execute commands manipulating stored strings.

        NOTE: Instead of string, this group is named value to avoid the confusion with the Java String type. Indeed, Redis strings can be strings, numbers, byte arrays...

        Specified by:
        value in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the value
        Parameters:
        redisKeyType - the type of the keys
        valueType - 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​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                                  com.fasterxml.jackson.core.type.TypeReference<V> valueType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to execute commands manipulating stored strings.

        NOTE: Instead of string, this group is named value to avoid the confusion with the Java String type. Indeed, Redis strings can be strings, numbers, byte arrays...

        Specified by:
        value in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the value
        Parameters:
        redisKeyType - the type of the keys
        valueType - 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 interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the member
        Parameters:
        redisKeyType - the type of the keys
        memberType - the type of the member stored in each set
        Returns:
        the object to manipulate sets.
      • set

        public <K,​V> ReactiveSetCommands<K,​V> set​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                              com.fasterxml.jackson.core.type.TypeReference<V> memberType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to execute commands manipulating sets.
        Specified by:
        set in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the member
        Parameters:
        redisKeyType - the type of the keys
        memberType - 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 interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the member
        Parameters:
        redisKeyType - the type of the keys
        memberType - the type of the member stored in each list
        Returns:
        the object to manipulate sets.
      • list

        public <K,​V> ReactiveListCommands<K,​V> list​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                                com.fasterxml.jackson.core.type.TypeReference<V> memberType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to execute commands manipulating lists.
        Specified by:
        list in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the member
        Parameters:
        redisKeyType - the type of the keys
        memberType - 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 interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the member
        Parameters:
        redisKeyType - the type of the keys
        memberType - the type of the member stored in the data structure
        Returns:
        the object to manipulate hyper log log data structures.
      • hyperloglog

        public <K,​V> ReactiveHyperLogLogCommands<K,​V> hyperloglog​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                                              com.fasterxml.jackson.core.type.TypeReference<V> memberType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to execute commands manipulating hyperloglog data structures.
        Specified by:
        hyperloglog in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        V - the type of the member
        Parameters:
        redisKeyType - the type of the keys
        memberType - 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 interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        Parameters:
        redisKeyType - the type of the keys
        Returns:
        the object to manipulate bitmap data structures.
      • bitmap

        public <K> ReactiveBitMapCommands<K> bitmap​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to execute commands manipulating bitmap data structures.
        Specified by:
        bitmap in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the key
        Parameters:
        redisKeyType - the type of the keys
        Returns:
        the object to manipulate bitmap data structures.
      • stream

        public <K,​F,​V> ReactiveStreamCommands<K,​F,​V> stream​(Class<K> redisKeyType,
                                                                                    Class<F> fieldType,
                                                                                    Class<V> valueType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to execute commands manipulating streams.
        Specified by:
        stream in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the redis key
        F - the type of the fields (map's keys)
        V - the type of the value
        Parameters:
        redisKeyType - the class of the keys
        fieldType - the class of the fields included in the message exchanged on the streams
        valueType - the class of the values included in the message exchanged on the streams
        Returns:
        the object to execute commands manipulating streams.
      • stream

        public <K,​F,​V> ReactiveStreamCommands<K,​F,​V> stream​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                                                    com.fasterxml.jackson.core.type.TypeReference<F> fieldType,
                                                                                    com.fasterxml.jackson.core.type.TypeReference<V> valueType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to execute commands manipulating streams.
        Specified by:
        stream in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of the redis key
        F - the type of the fields (map's keys)
        V - the type of the value
        Parameters:
        redisKeyType - the class of the keys
        fieldType - the class of the fields included in the message exchanged on the streams
        valueType - the class of the values included in the message exchanged on the streams
        Returns:
        the object to execute commands manipulating streams.
      • bloom

        public <K,​V> ReactiveBloomCommands<K,​V> bloom​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                                  com.fasterxml.jackson.core.type.TypeReference<V> valueType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to manipulate Bloom filters. This group requires the RedisBloom module.
        Specified by:
        bloom in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of keys
        V - the type of the values added into the Bloom filter
        Returns:
        the object to manipulate bloom values.
      • cuckoo

        public <K,​V> ReactiveCuckooCommands<K,​V> cuckoo​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                                    com.fasterxml.jackson.core.type.TypeReference<V> valueType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to manipulate Cuckoo filters. This group requires the RedisBloom module (including the Cuckoo filter support).
        Specified by:
        cuckoo in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of keys
        V - the type of the values added into the Cuckoo filter
        Returns:
        the object to manipulate Cuckoo values.
      • countmin

        public <K,​V> ReactiveCountMinCommands<K,​V> countmin​(Class<K> redisKeyType,
                                                                        Class<V> valueType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to manipulate Count-Min sketches. This group requires the RedisBloom module (including the count-min sketches support).
        Specified by:
        countmin in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of keys
        V - the type of the values added into the count-min sketches
        Returns:
        the object to manipulate count-min sketches.
      • countmin

        public <K,​V> ReactiveCountMinCommands<K,​V> countmin​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                                        com.fasterxml.jackson.core.type.TypeReference<V> valueType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to manipulate Count-Min sketches. This group requires the RedisBloom module (including the count-min sketches support).
        Specified by:
        countmin in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of keys
        V - the type of the values added into the count-min sketches
        Returns:
        the object to manipulate count-min sketches.
      • topk

        public <K,​V> ReactiveTopKCommands<K,​V> topk​(com.fasterxml.jackson.core.type.TypeReference<K> redisKeyType,
                                                                com.fasterxml.jackson.core.type.TypeReference<V> valueType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to manipulate Top-K list. This group requires the RedisBloom module (including the top-k list support).
        Specified by:
        topk in interface ReactiveRedisDataSource
        Type Parameters:
        K - the type of keys
        V - the type of the values added into the top-k lists
        Returns:
        the object to manipulate top-k lists.
      • pubsub

        public <V> ReactivePubSubCommands<V> pubsub​(Class<V> messageType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to publish and receive messages.
        Specified by:
        pubsub in interface ReactiveRedisDataSource
        Type Parameters:
        V - the type of message
        Parameters:
        messageType - the type of message
        Returns:
        the object to publish and subscribe to Redis channels
      • pubsub

        public <V> ReactivePubSubCommands<V> pubsub​(com.fasterxml.jackson.core.type.TypeReference<V> messageType)
        Description copied from interface: ReactiveRedisDataSource
        Gets the object to publish and receive messages.
        Specified by:
        pubsub in interface ReactiveRedisDataSource
        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 interface ReactiveRedisDataSource
        Returns:
        the underlying Redis client.
      • getVertx

        public io.vertx.mutiny.core.Vertx getVertx()