io.quarkus.redis.datasource.stream.XAddArgs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-redis-client Show documentation
Show all versions of quarkus-redis-client Show documentation
Connect to Redis in either imperative or reactive style
package io.quarkus.redis.datasource.stream;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import io.quarkus.redis.datasource.RedisCommandExtraArguments;
/**
* The argument of the XADD command.
*/
public class XAddArgs implements RedisCommandExtraArguments {
private String id;
private long maxlen = -1;
private boolean approximateTrimming;
private boolean nomkstream;
private String minid;
private long limit = -1;
/**
* Sets the stream id to identify a given entry inside a stream.
* If not set, the stream id is generated by the Redis server.
*
* @param id the id, must not be {@code null}, but be formed by two numbers separated by a {@code -}. In general,
* the first number is a timestamp.
* @return the current {@code XAddArgs}
*/
public XAddArgs id(String id) {
this.id = id;
return this;
}
/**
* Sets the max length of the stream.
* When {@code XADD} is called with this parameter, the new entry is added to the stream, but if the max size is
* reached, the oldest entry is evicted.
*
* @param maxlen the max length of the stream, must be positive
* @return the current {@code XAddArgs}
*/
public XAddArgs maxlen(Long maxlen) {
this.maxlen = maxlen;
return this;
}
/**
* When set, prefix the {@link #maxlen} with {@code ~} to enable the almost exact trimming.
* This is recommended when using {@link #maxlen(Long)}.
*
* @return the current {@code XAddArgs}
*/
public XAddArgs nearlyExactTrimming() {
this.approximateTrimming = true;
return this;
}
/**
* Do not create a new stream if the stream does not exist yet.
*
* @return the current {@code XAddArgs}
*/
public XAddArgs nomkstream() {
this.nomkstream = true;
return this;
}
/**
* Evicts entries from the stream having IDs lower to the specified one.
*
* @param minid the min id, must not be {@code null}, must be a valid stream id
* @return the current {@code XAddArgs}
*/
public XAddArgs minid(String minid) {
this.minid = minid;
return this;
}
/**
* Sets the maximum entries that can get evicted.
*
* @param limit the limit, must be positive
* @return the current {@code XAddArgs}
*/
public XAddArgs limit(long limit) {
this.limit = limit;
return this;
}
@Override
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy