All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.lettuce.core.TransactionResult Maven / Gradle / Ivy

Go to download

Advanced and thread-safe Java Redis client for synchronous, asynchronous, and reactive usage. Supports Cluster, Sentinel, Pipelining, Auto-Reconnect, Codecs and much more.

The newest version!
package io.lettuce.core;

import java.util.List;
import java.util.stream.Stream;

/**
 * Value interface for a {@code MULTI} transaction result. {@link TransactionResult} contains whether the transaction was rolled
 * back (i.e. conditional transaction using {@code WATCH}) and the {@link List} of transaction responses.
 *
 * @author Mark Paluch
 * @since 5.0
 */
public interface TransactionResult extends Iterable {

    /**
     * @return {@code true} if the transaction batch was discarded.
     * @since 5.1
     */
    boolean wasDiscarded();

    /**
     * @return {@code true} if the transaction batch was discarded.
     * @deprecated use renamed method {@link #wasDiscarded()} as Redis has no notion of rollback.
     */
    @Deprecated
    default boolean wasRolledBack() {
        return wasDiscarded();
    }

    /**
     * Returns the number of elements in this collection. If this {@link TransactionResult} contains more than
     * {@link Integer#MAX_VALUE} elements, returns {@link Integer#MAX_VALUE}.
     *
     * @return the number of elements in this collection
     */
    int size();

    /**
     * Returns {@code true} if this {@link TransactionResult} contains no elements.
     *
     * @return {@code true} if this {@link TransactionResult} contains no elements
     */
    boolean isEmpty();

    /**
     * Returns the element at the specified position in this {@link TransactionResult}.
     *
     * @param index index of the element to return
     * @param  inferred type
     * @return the element at the specified position in this {@link TransactionResult}
     * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size())
     */
     T get(int index);

    /**
     * Returns a sequential {@code Stream} with this {@link TransactionResult} as its source.
     *
     * @return a sequential {@code Stream} over the elements in this {@link TransactionResult}
     */
    Stream stream();

}